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

Event conflation #84

Closed
genaku opened this issue Jul 14, 2017 · 2 comments
Closed

Event conflation #84

genaku opened this issue Jul 14, 2017 · 2 comments

Comments

@genaku
Copy link

genaku commented Jul 14, 2017

I've read Guide to UI programming with coroutines. Event conflation. But unfortunately didn't catch one moment. For example I have switching button (with 3 or more states), which starts some "long" task depending on button state. Button should change state quickly on every click, but task (as it can't switch so fast) should switch only to most recent state from eventActor. So how to realize it? Should I keep two actors in fun Node.onClick>: one for UI (with capacity = default) and another for processing (with capacity = Channel.CONFLATED). Or it can be done other way?

@elizarov
Copy link
Contributor

I don't think that you need an actor to keep track of a synchronous updates that should happen in your application. Actors are designed to help you manage your asynchronous jobs. If you have a switching button with 3 states then you should directly change its state on every click without adding a layer of indirection via actor. You should use an actor to launch whatever asynchronous job you need to be tied to those synchronous changes in state.

@genaku
Copy link
Author

genaku commented Jul 21, 2017

Thank you for answer. I used button to check technology. Actual use is RecyclerView filled by query from database. Tap on item of RecyclerView update field of record in database (UI state) forcing to refresh RecyclerView item state. At the same time this tap on RecyclerView item should try to change long time task.

@elizarov elizarov closed this as completed Nov 6, 2017
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