-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,40 @@ | ||
# [1](https://github.com/platojobs/SFLOG/issues/186) | ||
|
||
总有一天,你会对著过去的伤痛微笑。你会感谢离开你的那个人,他配不上你的爱、你的好、你的痴心。他终究不是命定的那个人。幸好他不是。 | ||
`smaple` 除了订阅源obs以外,还可以监视另外一个notifier | ||
之间有源就取最新的源发送 | ||
两次`noti`之间如果没有源的话,就不会发送 | ||
|
||
```swift | ||
|
||
func sample(){ | ||
let disbag = DisposeBag() | ||
let source1 = PublishSubject<Int>() | ||
let noti1 = PublishSubject<String>() | ||
source1.sample(noti1) | ||
.subscribe(onNext: { | ||
print($0) | ||
},onCompleted: { | ||
print("1===completed") | ||
}).disposed(by: disbag) | ||
|
||
source1.onNext(1) //1 | ||
noti1.onNext("A") | ||
source1.onNext(2) //2 | ||
noti1.onNext("B") | ||
noti1.onNext("C") | ||
source1.onNext(3) | ||
source1.onNext(4) | ||
noti1.onNext("D") | ||
source1.onNext(5) | ||
noti1.onCompleted() | ||
/* | ||
1 | ||
2 | ||
4 | ||
5 | ||
*/ | ||
} | ||
|
||
|
||
``` | ||
|
||
—— 张小娴 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters