ScheduledItem
包装了状态即状态处理函数
会被放到当前线程的某个队列(实现为Queue的一个数据结构)中,由CurrentThreadScheduler实现
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
struct ScheduledItem<T>
: ScheduledItemType
, InvocableType {
typealias Action = (T) -> Disposable
private let _action: Action
private let _state: T
private let _disposable = SingleAssignmentDisposable()
var isDisposed: Bool {
return self._disposable.isDisposed
}
init(action: @escaping Action, state: T) {
self._action = action
self._state = state
}
func invoke() {
self._disposable.setDisposable(self._action(self._state))
}
func dispose() {
self._disposable.dispose()
}
}
Queue见另一篇
注:文中源码来自RxSwift