Polished playgrounds
All errors have been fixed for PG: * Introduction * Subjects
This commit is contained in:
parent
ba05314a98
commit
554addd805
|
|
@ -177,7 +177,7 @@ This filter tracks the last value emitted and removes like values. This function
|
|||
|
||||
example("distinctUntilChanged") {
|
||||
let distinctUntilChangedSubscriber = sequence(1, 2, 3, 1, 1, 4)
|
||||
.distinctUntilChanged
|
||||
.distinctUntilChanged()
|
||||
.subscribeNext { value in
|
||||
print("\(value)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='osx' requires-full-environment='true'>
|
||||
<playground version='5.0' target-platform='osx' requires-full-environment='true' executeOnSourceChanges='NO'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
||||
|
|
@ -15,55 +15,55 @@ func writeSequenceToConsole(name: String, sequence: Observable<String>) {
|
|||
}
|
||||
|
||||
|
||||
ex/*:
|
||||
/*:
|
||||
|
||||
## PublishSubject
|
||||
|
||||
PublishSubject can begin emitting items immediately upon creation, but there is a risk that one or more items may be lost between the time the Subject is created and the observer subscribes to it.
|
||||
|
||||
*/
|
||||
ample("PublishSubject") {
|
||||
example("PublishSubject") {
|
||||
let subject = PublishSubject<String>()
|
||||
writeSequenceToConsole("1", subject)
|
||||
writeSequenceToConsole("1", sequence: subject)
|
||||
sendNext(subject, "a")
|
||||
sendNext(subject, "b")
|
||||
writeSequenceToConsole("2", subject)
|
||||
writeSequenceToConsole("2", sequence: subject)
|
||||
sendNext(subject, "c")
|
||||
sendNext(subject, "d")
|
||||
}
|
||||
|
||||
|
||||
ex/*:
|
||||
/*:
|
||||
|
||||
## ReplaySubject
|
||||
|
||||
ReplaySubject emits to any observer all of the items, in the buffer, that were emitted by the source
|
||||
|
||||
*/
|
||||
ample("ReplaySubject") {
|
||||
example("ReplaySubject") {
|
||||
let subject = ReplaySubject<String>(bufferSize: 1)
|
||||
writeSequenceToConsole("1", subject)
|
||||
writeSequenceToConsole("1", sequence: subject)
|
||||
sendNext(subject, "a")
|
||||
sendNext(subject, "b")
|
||||
writeSequenceToConsole("2", subject)
|
||||
writeSequenceToConsole("2", sequence: subject)
|
||||
sendNext(subject, "c")
|
||||
sendNext(subject, "d")
|
||||
}
|
||||
|
||||
|
||||
ex/*:
|
||||
/*:
|
||||
|
||||
## BehaviorSubject a.k.a. Variable
|
||||
|
||||
ReplaySubject emits to any observer all of the items, in the buffer, that were emitted by the source
|
||||
|
||||
*/
|
||||
ample("ReplaySubject") {
|
||||
example("ReplaySubject") {
|
||||
let subject = BehaviorSubject(value: "z")
|
||||
writeSequenceToConsole("1", subject)
|
||||
writeSequenceToConsole("1", sequence: subject)
|
||||
sendNext(subject, "a")
|
||||
sendNext(subject, "b")
|
||||
writeSequenceToConsole("2", subject)
|
||||
writeSequenceToConsole("2", sequence: subject)
|
||||
sendNext(subject, "c")
|
||||
sendNext(subject, "d")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='osx' requires-full-environment='true' display-mode='rendered'>
|
||||
<playground version='5.0' target-platform='osx' requires-full-environment='true' display-mode='rendered' executeOnSourceChanges='NO'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
||||
Loading…
Reference in New Issue