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

Add the ability to handle global state changes #28

Open
haroldadmin opened this issue Jan 29, 2020 · 0 comments
Open

Add the ability to handle global state changes #28

haroldadmin opened this issue Jan 29, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@haroldadmin
Copy link
Owner

Is your feature request related to a problem? Please describe.
There are several pieces of state in an app that need to be accessed globally, such as a user's auth status. Additionally, there are also some events that can be dispatched from anywhere in the app to affect this global state, for example an auth token expiration triggering a logout.

These events are not a part of a single screen's state, but rather the global state, but Vector currently does not do anything to help handle these cases.

Describe the solution you'd like

  • Implement a global state store alongside the existing state-stores for each screen. This global state store should be accessible everywhere, without having to use a ViewModel for it.

  • Add support for dispatching actions to this state store, so that any part of an app can send events to it.

  • Add ability to observe this state-changes in this store.

  • Maybe look into the ability to have multiple global state stores, such as one for Navigation, another for Authentication, etc? This effect can also be achieved by using a generic single state-store containing all different state classes as children of a parent sealed class.

Describe alternatives you've considered
An alternative to this would be to use an activity scoped ViewModel with multiple Fragments and share this ViewModel between them. This effectively leads to a global state store for all these fragments. While this solution will work well for single activity apps, it doesn't work when multiple activities are involved.

@haroldadmin haroldadmin added the enhancement New feature or request label Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant