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

Changes default parameter which is queue in sink -> .mainIsolated() #193

Merged
merged 3 commits into from
Nov 21, 2020

Conversation

muukii
Copy link
Collaborator

@muukii muukii commented Nov 21, 2020

sinkState and sinkValue uses .main in queue parameter as a default.
.main emits the events as possible synchronously if these come from main-queue.
In order to do this synchronously, it requires enqueuing events is zero.
However, .main is a shared-instance, the events dispatch to the main queue asynchronously.

sink's use-cases are mostly UI binding, it's probably unuseful dispatching the first event asynchronously while building UI.
It might cause several glitches and meaningless blank states.

So, we change the default parameter to .mainIsolated().
with this, each sink method receives the events synchronously if it's possible.
At least, the first event would be delivered synchronously.

One more thing,
This PR includes a new factory method in TargetQueue.
Which is TargetQueue.startsFromCurrentThread(andUse: )
This enables to receive the first event on the current-thread which started sink.
From then it receives on specified TargetQueue.

This might cover all of the use-cases for building UI.
In UIKit, you would start sink on main-queue, In Texture you can start sink on any-queue but it's better to get the first event on the current-thread.

@muukii muukii merged commit 0c1ff75 into master Nov 21, 2020
@muukii muukii deleted the muukii/isolated branch November 21, 2020 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant