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

Updating appstate without useraction #98

Closed
SGuzel opened this issue Jan 22, 2019 · 5 comments
Closed

Updating appstate without useraction #98

SGuzel opened this issue Jan 22, 2019 · 5 comments

Comments

@SGuzel
Copy link

SGuzel commented Jan 22, 2019

Hi all,
i have some card items to layout within a listview which are stored in an appstate but the ui changes do not triggered by any user. The ui should only be updated by a server which has the itemstates too. The server streams the new item states constantly.

Like

Item { ValueChanged<bool> isConnected; }

Client.isConnected.addlistener( handleChange )
handleChange(){ updateAppState () ) ---> rebuild Widgets

How can I archieve this?
Maybe a litte help or example?

Thank you .

@brianegan
Copy link
Owner

Hey hey -- in this case, you'll want to use a Middleware function! It will be responsible for connecting to the Stream of information at the correct time, and dispatching actions when new data comes in.

This article does a good job of explaining the process, using Firestore as the Streaming data source: https://medium.com/shift-studio/flutter-redux-and-firebase-cloud-firestore-in-sync-2c1accabdac4

@SGuzel
Copy link
Author

SGuzel commented Jan 22, 2019

Hi again, thank you very much. That seems to be the solution. I already have middleware but somehow I could not connect the middleware to the grpc/protobuf client which is streaming the notifications.

;)

@brianegan
Copy link
Owner

Ah, gotcha! Yah, hopefully you can just do a myGrpcClient.dataStream.listen((data) => store.dispatch(ReceivedPayloadAction(data)) inside your Middleware and you'll be all good!

Please let me know if I can help further :)

@SGuzel
Copy link
Author

SGuzel commented Jan 22, 2019

Thank you very much i will just try it out. Since the app is getting more complicated, I changed my mind and try to use redux instead of managing the state manually.

I appreciate it very much. thank you for answering so quickly.

@SGuzel
Copy link
Author

SGuzel commented Jan 30, 2019

I have now a working version of my code using redux and grpc client. Thank you @brianegan

@SGuzel SGuzel closed this as completed Jan 30, 2019
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

2 participants