From 554addd805c4ea09d70504cc4aab149bccdea8d7 Mon Sep 17 00:00:00 2001 From: Leonard Date: Sat, 15 Aug 2015 19:00:59 +0200 Subject: [PATCH] Polished playgrounds All errors have been fixed for PG: * Introduction * Subjects --- .../Introduction.playground/Contents.swift | 2 +- .../contents.xcplayground | 2 +- .../Subjects.playground/Contents.swift | 24 +++++++++---------- .../Subjects.playground/contents.xcplayground | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Playgrounds/Introduction.playground/Contents.swift b/Playgrounds/Introduction.playground/Contents.swift index 1294a2f1..605fcc71 100644 --- a/Playgrounds/Introduction.playground/Contents.swift +++ b/Playgrounds/Introduction.playground/Contents.swift @@ -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)") } diff --git a/Playgrounds/Introduction.playground/contents.xcplayground b/Playgrounds/Introduction.playground/contents.xcplayground index a204ba67..cd0e4318 100644 --- a/Playgrounds/Introduction.playground/contents.xcplayground +++ b/Playgrounds/Introduction.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Playgrounds/Subjects.playground/Contents.swift b/Playgrounds/Subjects.playground/Contents.swift index ef67cdd0..0e5747af 100644 --- a/Playgrounds/Subjects.playground/Contents.swift +++ b/Playgrounds/Subjects.playground/Contents.swift @@ -15,55 +15,55 @@ func writeSequenceToConsole(name: String, sequence: Observable) { } -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() - 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(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") } diff --git a/Playgrounds/Subjects.playground/contents.xcplayground b/Playgrounds/Subjects.playground/contents.xcplayground index 0b962190..e5efec80 100644 --- a/Playgrounds/Subjects.playground/contents.xcplayground +++ b/Playgrounds/Subjects.playground/contents.xcplayground @@ -1,4 +1,4 @@ - + \ No newline at end of file