-
-
Notifications
You must be signed in to change notification settings - Fork 417
Closed
Labels
Description
This is an issue I keep getting stuck at in different context. When the parent needs to listen of events of the child, how do you break or avoid a cycle?
e.g.
function List(sources) {
const actions = intent({ ...sources, click$: ??? })
const state = model(actions).shareReplay(1)
const items$ = state
.flatMapLatest(({ items, selected }) =>
items.map(item => Item({
...sources,
props$: Observable.of({ id: item.id, selected: item.id === 'selected' })
}))
const click$ = items$.map(items => Observable.merge(...items.map(item => item.click$)))
return {
...
}
}Basically the following flow:
click => List => selected => Item => click
Which gives me a cycle. How do I get around this? I could use a proxy as I've seen in some examples:
const clickProxy = new Subject()
const actions = intent({ ...sources, click$: clickProxy })
const subscription = click$.subscribe(clickProxy)
// subscription leaks...However, that gives me a memory leak...
Reactions are currently unavailable