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

Change default argument in sink and derived #158

Merged
merged 4 commits into from Sep 12, 2020
Merged

Conversation

muukii
Copy link
Collaborator

@muukii muukii commented Sep 11, 2020

To be faster in mutating the state.
Currently, starting Sink and deriving value from the state are running never dispatching as default.
that means the commit operations have to wait for it until all of the updating value finished.

As an original strategy, I decided to use such as this current behavior to achieve an easier way to debug because we can see all of stack-trace with running synchronously.

However, in most cases in the real world, it is not necessary from my current view.
Basically new value from subscribing like sink except creating Derive object. (Derive object requires the first value synchronously in init.)

So, This PR offers us to use DispatchQueue with asynchronously to receive a new value.
There are differences in Sink and making Derived.

Sink uses .asyncMain : it always dispatches to main-queue to deliver new value to the closure.
Derived object uses .asyncSerialBackground : it always dispatches to the background serial queue to derive new value.

In according, commit operation becomes no needs to wait for finishing updating values for each subscriber.

If you need to receive a new value synchronously, you can specify .passthrough like our unit testing code.

@muukii
Copy link
Collaborator Author

muukii commented Sep 11, 2020

8.0.0 would include this PR

@muukii
Copy link
Collaborator Author

muukii commented Sep 11, 2020

TODO: consider sinkState sinkValue should emit the first value synchronously.

@muukii muukii changed the base branch from master to v8.0.0-branch September 12, 2020 07:18
@muukii muukii merged commit 0a169a5 into v8.0.0-branch Sep 12, 2020
@muukii muukii deleted the muukii/derived branch September 12, 2020 07:19
@muukii muukii mentioned this pull request Sep 12, 2020
muukii added a commit that referenced this pull request Oct 8, 2020
* Change default argument in sink and derived (#158)

* Use background target queue in Derived

* Sink use default asyncMain

* Default asyncSerialBackground

* Fix test

* Update podspec

* Fix TargetQueue.main (#163)

* Patch

* Fix tests

* Add macro

* Update TargetQueue

* Update queue

* 🌲 Update

* update .main

* Fix test
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.

None yet

1 participant