Derived store problem #573
-
I have a store
Now I expect B listener to run after the mapping has been updated, but it seems it doesn't. I also get warnings that .on is deprecated for derived stores. How can I tackle this? so I would like to have somewhat like this: A(fx.done) -> update A -> update B -> B(fx.done) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@mendrik You MUST not to add |
Beta Was this translation helpful? Give feedback.
-
I could not understand the problem by looking at the code, but I think it should be something like this: const $rawTree = createStore<Node>...)
.on(createNodeFx.doneData, (state, result) => result.tree)
export const $tree = $rawTree.map(unless(isNil, TreeNode.from<Node, 'children'>('children')))
sample({
source: $tree,
clock: createNodeFx.doneData
fn: (state, result) => state.first(propEq('id', result.nodeId)) ?? null,
target: selectNode,
}) |
Beta Was this translation helpful? Give feedback.
@mendrik You MUST not to add
.on
to derived stores. Derived stores MUST be updated only by its parent store.