Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribing observables to other observables #48

Open
WhitWaldo opened this issue Feb 6, 2021 · 1 comment
Open

Subscribing observables to other observables #48

WhitWaldo opened this issue Feb 6, 2021 · 1 comment

Comments

@WhitWaldo
Copy link

I'd like to have observables be able to subscribe directly to other observables so they might update their own values reactively.

Today, I can solve this imperatively. If I have a ParentStore and a ChildStore, I can inject the latter into the former. Within ParentStore, when an action method is called to update a value imperatively, I can point to my ChildStore reference and imperatively call an action on it in order to effect some changed value on it.

The downside to doing it this way is that my DI registration winds up having to be far too knowledgeable about what stores are intending to be subscribed to what as I fill the constructor of each store with injected instances of each other dependent store. Further, it's suddenly not reactive so much as imperative, leaving the only reactive component being the state rendered in Blazor.

What am I missing that would allow observables to subscribe to values on other observables and in turn be able to change their own values? Thank you!

@jspuij
Copy link
Owner

jspuij commented Apr 29, 2021

@WhitWaldo I'm not sure I'm following you without a small sample, but the most obvious way would be to build a tree from your observable state and attach everything to the same shared state. There is no concept of a store in Cortex.Net, there is just observable state, with reactions tied to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants