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

Store/waitCondition access in 22+ #152

Closed kuhnroyal closed 6 months ago

kuhnroyal commented 6 months ago

There are some awesome changes in the latest version(s), really like that!

I have built a wrapper around StoreConnector that waits until a waitCondition is met before doing its magic.

I am now missing a way to access store.waitCondition. My wrapper also manually calls the OnInitCallback which requires the store as parameter and I also have no more access to this.

  1. Is there a way to get the store?
  2. Is there a way to get the state without listening? Basically something like context.getState(listen: false)?
  3. Can I access the waitCondition function without having a store?

Thanks!

marcglasberg commented 6 months ago

I'm glad you like the new features!

Please upgrade to version 22.4.5.

From StoreProvider, VmFactory and ReduxAction you should now have direct access to:

Now StoreProvider.state has a notify parameter for you to get the state without rebuilding (and so do isWaiting, isFailed, exceptionFor and clearExceptionFor).

You can get the store with StoreProvider.backdoorInheritedWidget but that's only for advanced use cases, like yours. The reason it's not exposed simply as store is because people could use it to get the state, and it wouldn't rebuild when the state changes. That's almost always the wrong way to get the state.

kuhnroyal commented 5 months ago

Thanks I checked and seem to be able to adjust everything now!