From db62a3cf3f0e39c518aca73ac5a8093361887aa2 Mon Sep 17 00:00:00 2001 From: Ben Shewmake Date: Fri, 27 May 2016 17:57:09 -0600 Subject: [PATCH 1/2] Added changed '.subscribe' to '.subscribeNext' to alleviate error output in debug console. --- .../Contents.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift index 064b5028..a5c3ee52 100644 --- a/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift @@ -75,7 +75,7 @@ example("single with conditions") { Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .single { $0 == "🔵" } - .subscribe { print($0) } + .subscribeNext { print($0) } .addDisposableTo(disposeBag) } /*: From 0514c039639242cfa5a4b42d2a3c34af6d48aa86 Mon Sep 17 00:00:00 2001 From: Ben Shewmake Date: Tue, 7 Jun 2016 19:42:05 -0600 Subject: [PATCH 2/2] Added two additional examples to Filtering and Conditional Operators: "single with conditions". Per suggestion by @scotteg, two additional examples were added to cover the following use cases: * A successful matching case of exactly one element * An error when repeated elements are observed --- .../Contents.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift index a5c3ee52..c885603a 100644 --- a/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift @@ -73,9 +73,19 @@ example("single") { example("single with conditions") { let disposeBag = DisposeBag() + Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") + .single { $0 == "🐸" } + .subscribe { print($0) } + .addDisposableTo(disposeBag) + + Observable.of("🐱", "🐰", "🐶", "🐱", "🐰", "🐶") + .single { $0 == "🐰" } + .subscribe { print($0) } + .addDisposableTo(disposeBag) + Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .single { $0 == "🔵" } - .subscribeNext { print($0) } + .subscribe { print($0) } .addDisposableTo(disposeBag) } /*: