-
-
Notifications
You must be signed in to change notification settings - Fork 418
tl;dr version
There are 4 solutions:
- Manually build the dataflow, which will contain circular dependencies. Check out this example
- Global state at the top-most component (main).
- Use Stanga and similars.
- Use Cycle Collections
For more information on the pros and cons of each method, look at this issue for more info.
There's a few ways to go about managing your application state.
-
Using a fold/scan to change the state over time in your model. For more advanced example look at cyclejs/examples. Simple example shown below.
// intent const add$ = sources.DOM.select('.add').events('click').mapTo(1) const minus$ = sources.DOM.select('.minus').events('click').mapTo(-1) const action$ = xs.merge(add$, minus$) // model const state$ = action$.fold((x, y) => x + y, 0)
-
Using stanga but does not adhere to the CycleJS philosophy
Look at this issue for more info.
Usually the answer is to use snabbdom hooks. If the component provides callbacks of interest, emit custom events on the vnode.elm from within the callbacks. Custom events can have any name, and can be caught through domSource.select().events().
Have a look at cyclejs-sortable for examples for custom event use and look at this issue for more info.