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

Guidance on sharing state between components #63

Open
pieterdd opened this issue Mar 24, 2024 · 0 comments
Open

Guidance on sharing state between components #63

pieterdd opened this issue Mar 24, 2024 · 0 comments

Comments

@pieterdd
Copy link

It would be nice to have some guidance on best practices regarding state sharing between Relm4 components. These are the options I've considered so far:

  • Introduce global state using SharedState. This is relatively easily to implement but may make it harder to write isolated automated tests. The tab_game example uses this approach.
  • Pass down references to child components. I tried this at some point and got stuck trying to express the lifetime constraints.
  • Perhaps passing down RefCell/RefMut variables could work. Haven't tried this yet. It may sidestep lifetime issues but could introduce runtime panics if not managed properly.
  • Rely fully on message passing as opposed to shared state. This may be elaborate to maintain especially if there's a big hierarchy in your components.
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

1 participant