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

Added a debounce helper #237

Merged
merged 3 commits into from
Dec 2, 2018

Conversation

TimLariviere
Copy link
Member

@TimLariviere TimLariviere commented Nov 24, 2018

Closes #161

Added an helper, along fix and fixf, that throttle calls to a function.
Really quick updates (like TextChanged) can make Fabulous go out of sync on Android between what it thinks the state is and what it really is, resulting in an infinite loop where Fabulous both tries to force down its values and tries to catch up with Android.
The debounce function prevents Fabulous to react too often to those updates which helps it follow the correct state, e.g.

View.Entry(
     text=model.MyEntryText,
     textChanged=debounce 250 (fun args -> dispatch (MyEntryTextChanged args.NewTextValue))
)

In this example, the message will be dispatched only if TextChanged is not triggered for 250ms since its last call.
The Text property will only be updated then.

@TimLariviere TimLariviere merged commit 35b391e into fabulous-dev:master Dec 2, 2018
@TimLariviere TimLariviere deleted the 161-debounce-helper branch December 2, 2018 10:28
@TimLariviere TimLariviere mentioned this pull request Dec 3, 2018
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

Successfully merging this pull request may close these issues.

Infinite loop when messages are sent too quickly in succession
1 participant