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

Add EventScheduler support #27

Merged
merged 2 commits into from Nov 6, 2020
Merged

Add EventScheduler support #27

merged 2 commits into from Nov 6, 2020

Conversation

bramschulting
Copy link
Contributor

This PR adds support for event schedulers.

Schedulers can be used to schedule the events of your observation. By default, Hanson uses the CurrentThreadScheduler, which immediatly sends events on whatever thread it currently is. Hanson also offers the MainThreadScheduler, which ensures events are sent on the main thread. This is useful when observing a value that can change from a background thread and you want to do UI changes based on that value.

This introduces a breaking change to the EventPublisher protocol. The eventHandlers type has been changed to add support for event schedulers.

Schedulers can be used to schedule the events of your observation. By default, Hanson uses the `CurrentThreadScheduler`, which immediatly sends events on whatever thread it currently is. Hanson also offers the `MainThreadScheduler`, which ensures events are sent on the main thread. This is useful when observing a value that can change from a background thread and you want to do UI changes based on that value.

This introduces a breaking change to the `EventPublisher` protocol. The `eventHandlers` type has been changed to add support for event schedulers.
@bramschulting bramschulting merged commit 1729d17 into master Nov 6, 2020
@bramschulting bramschulting deleted the add-scheduler branch November 6, 2020 14:35
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.

None yet

3 participants