haroldadmin / Vector

Kotlin Coroutines based MVI architecture library for Android
https://haroldadmin.github.io/Vector/
Apache License 2.0
193 stars 9 forks source link

Add the ability to handle global state changes #28

Open haroldadmin opened 4 years ago

haroldadmin commented 4 years ago

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

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.