marcglasberg / async_redux

Flutter Package: A Redux version tailored for Flutter, which is easy to learn, to use, to test, and has no boilerplate. Allows for both sync and async reducers.
Other
230 stars 41 forks source link

Dependency management via Environment #108

Closed craigomac closed 3 years ago

craigomac commented 3 years ago

References #107.

Just to explain what I mean, I've created this PR. You're free to decide if it's philosophically the right direction for this project, and if so I'm also happy to clear things up and add more tests.


This PR adds a dependency container to Store in the form of an "environment", set at the time of the store's creation. It can be accessed by ReduxActions by reading the environment field, in the same way as they currently read state.

The environment is to be used for attaching dependencies shared by actions. For example, you could pass a GetIt instance if you prefer to use it. The advantage of attaching it to the store is clear: a single point of configuration.