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

Usage with a SPA #11

Closed
formula349 opened this issue May 20, 2015 · 2 comments
Closed

Usage with a SPA #11

formula349 opened this issue May 20, 2015 · 2 comments

Comments

@formula349
Copy link

When using this framework with a single page application, how do you handle the unique state and signals used by each page within the application?

The state seems to be fairly easy to solve by nesting it within the app state and using a map to always refer to the current page state.

The signals seem to be the issue. There doesn't seem to be a concept of nested signals or signals attached to nodes within the tree. I was initially looking for some type of cursor like Baobab that I could select and perhaps attach signals to the cursor.

let pageCursor = cerebral.select(['pages', 'landing']);
pageCursor.signal('modifyDashboardClicked', modifyDashboard);

Then I could attach this cursor/cerebral sub-instance to the react component rendering the particular page and all of it's state and signals would be available.

Maybe this is a bad idea or way out of scope, but any guidance would be appreciated.

@christianalfoni
Copy link
Member

Hi @formula349 ,

Thanks for great input!

I can say that it is currently out of scope and I think we need a bit more experience before deciding something.

What I can say for now is that it does add complexity. There is no longer a single point to define and use signals, you have to know at what path that signal is related to. I think it also would be more difficult to refactor such a signal.

Maybe it is a better idea to have multiple cerebral instances? So if each site actually does not have anything to do with the other you could consider it "a different person". So you have two different top components where you inject two different cerebrals. Would that make sense?

@christianalfoni
Copy link
Member

reading this issue again I think it breaks the architecture. Signals has no knowledge of state and that is important, they only request state changes. Though I do think we will meet issues with structuring larger applications, but I think we should wait to solve that until we have some more examples.

So I am all for some sort of dividing signals and possibly an entrypath to state changes, but not base signals on a specific state. Again, let me know if you get into trouble and we can bring up a discussion on it :-)

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