Changes default parameter which is queue in sink -> .mainIsolated() #193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
sinkState
andsinkValue
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.