Skip to content
Permalink
Browse files

Add a documentation for scheduling

  • Loading branch information
devxoul committed Oct 21, 2019
1 parent e2b989b commit 590bb7040a0c7dc53d5671f2bd62e7980043b760
Showing with 17 additions and 0 deletions.
  1. +17 −0 README.md
@@ -30,6 +30,7 @@ You may want to see the [Examples](#examples) section first if you'd like to see
* [Global States](#global-states)
* [View Communication](#view-communication)
* [Testing](#testing)
* [Scheduling](#scheduling)
* [Examples](#examples)
* [Dependencies](#dependencies)
* [Requirements](#requirements)
@@ -342,6 +343,22 @@ func testIsLoading() {
}
```
### Scheduling
Define `scheduler` property to specify which scheduler is used for reducing and observing the state stream. Note that this queue **must be** a serial queue. The default scheduler is `CurrentThreadScheduler`.
```swift
final class MyReactor: Reactor {
let scheduler: Scheduler = SerialDispatchQueueScheduler(qos: .default)
func reduce(state: State, mutation: Mutation) -> State {
// executed in a background thread
heavyAndImportantCalculation()
return state
}
}
```
## Examples
* [Counter](https://github.com/ReactorKit/ReactorKit/tree/master/Examples/Counter): The most simple and basic example of ReactorKit

0 comments on commit 590bb70

Please sign in to comment.
You can’t perform that action at this time.