Skip to content

Commit

Permalink
Update the playground with the renamed SignalProducer initializers.
Browse files Browse the repository at this point in the history
  • Loading branch information
andersio committed Dec 3, 2016
1 parent 593ae80 commit f2d288e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ scopedExample("`mapError`") {
Preserves only the values of the producer that pass the given predicate.
*/
scopedExample("`filter`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.filter { $0 > 3 }
.startWithValues { value in
print(value)
Expand All @@ -275,7 +275,7 @@ Returns a producer that will yield the first `count` values from the
input producer.
*/
scopedExample("`take(first:)`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.take(first: 2)
.startWithValues { value in
print(value)
Expand All @@ -288,7 +288,7 @@ Forwards all events onto the given scheduler, instead of whichever
scheduler they originally arrived upon.
*/
scopedExample("`observe(on:)`") {
let baseProducer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
let baseProducer = SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
let completion = { print("is main thread? \(Thread.current.isMainThread)") }

baseProducer
Expand Down Expand Up @@ -391,8 +391,8 @@ least one value each. If either producer is interrupted, the returned producer
will also be interrupted.
*/
scopedExample("`combineLatest(with:)`") {
let producer1 = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
let producer2 = SignalProducer<Int, NoError>(values: [ 1, 2 ])
let producer1 = SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
let producer2 = SignalProducer<Int, NoError>([ 1, 2 ])

producer1
.combineLatest(with: producer2)
Expand All @@ -407,7 +407,7 @@ Returns a producer that will skip the first `count` values, then forward
everything afterward.
*/
scopedExample("`skip(first:)`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.skip(first: 2)
.startWithValues { value in
print(value)
Expand All @@ -427,7 +427,7 @@ the Event itself and then complete. When an Interrupted event is received,
the resulting producer will send the Event itself and then interrupt.
*/
scopedExample("`materialize`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.materialize()
.startWithValues { value in
print(value)
Expand All @@ -447,8 +447,8 @@ multiple times) by `sampler`, then complete once both input producers have
completed, or interrupt if either input producer is interrupted.
*/
scopedExample("`sample(on:)`") {
let baseProducer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
let sampledOnProducer = SignalProducer<Int, NoError>(values: [ 1, 2 ])
let baseProducer = SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
let sampledOnProducer = SignalProducer<Int, NoError>([ 1, 2 ])
.map { _ in () }

baseProducer
Expand All @@ -466,7 +466,7 @@ is the current value. `initial` is supplied as the first member when `self`
sends its first value.
*/
scopedExample("`combinePrevious`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.combinePrevious(42)
.startWithValues { value in
print("\(value)")
Expand All @@ -482,7 +482,7 @@ producer returned from `scan`. That result is then passed to `combine` as the
first argument when the next value is emitted, and so on.
*/
scopedExample("`scan`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.scan(0, +)
.startWithValues { value in
print(value)
Expand All @@ -494,7 +494,7 @@ scopedExample("`scan`") {
Like `scan`, but sends only the final value and then immediately completes.
*/
scopedExample("`reduce`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.reduce(0, +)
.startWithValues { value in
print(value)
Expand All @@ -507,7 +507,7 @@ Forwards only those values from `self` which do not pass `isRepeat` with
respect to the previous value. The first value is always forwarded.
*/
scopedExample("`skipRepeats`") {
SignalProducer<Int, NoError>(values: [ 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 4 ])
SignalProducer<Int, NoError>([ 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 4 ])
.skipRepeats(==)
.startWithValues { value in
print(value)
Expand All @@ -521,7 +521,7 @@ at which point the returned signal behaves exactly like `self`.
*/
scopedExample("`skip(while:)`") {
// Note that trailing closure is used for `skip(while:)`.
SignalProducer<Int, NoError>(values: [ 3, 3, 3, 3, 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 3, 3, 3, 3, 1, 2, 3, 4 ])
.skip { $0 > 2 }
.startWithValues { value in
print(value)
Expand Down Expand Up @@ -566,7 +566,7 @@ Waits until `self` completes and then forwards the final `count` values
on the returned producer.
*/
scopedExample("`take(last:)`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.take(last: 2)
.startWithValues { value in
print(value)
Expand All @@ -579,7 +579,7 @@ Unwraps non-`nil` values and forwards them on the returned signal, `nil`
values are dropped.
*/
scopedExample("`skipNil`") {
SignalProducer<Int?, NoError>(values: [ nil, 1, 2, nil, 3, 4, nil ])
SignalProducer<Int?, NoError>([ nil, 1, 2, nil, 3, 4, nil ])
.skipNil()
.startWithValues { value in
print(value)
Expand All @@ -593,8 +593,8 @@ Zips elements of two producers into pairs. The elements of any Nth pair
are the Nth elements of the two input producers.
*/
scopedExample("`zip(with:)`") {
let baseProducer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
let zippedProducer = SignalProducer<Int, NoError>(values: [ 42, 43 ])
let baseProducer = SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
let zippedProducer = SignalProducer<Int, NoError>([ 42, 43 ])

baseProducer
.zip(with: zippedProducer)
Expand Down Expand Up @@ -651,7 +651,7 @@ which case `replacement` will not be started, and none of its events will be
be forwarded. All values sent from `producer` are ignored.
*/
scopedExample("`then`") {
let baseProducer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
let baseProducer = SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
let thenProducer = SignalProducer<Int, NoError>(value: 42)

baseProducer
Expand Down Expand Up @@ -686,7 +686,7 @@ a layer of caching in front of another `SignalProducer`.
This operator has the same semantics as `SignalProducer.buffer`.
*/
scopedExample("`replayLazily(upTo:)`") {
let baseProducer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4, 42 ])
let baseProducer = SignalProducer<Int, NoError>([ 1, 2, 3, 4, 42 ])
.replayLazily(upTo: 2)

baseProducer.startWithValues { value in
Expand All @@ -712,7 +712,7 @@ If `self` or any of the created producers fail, the returned producer
will forward that failure immediately.
*/
scopedExample("`flatMap(.latest)`") {
SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
.flatMap(.latest) { SignalProducer(value: $0 + 3) }
.startWithValues { value in
print(value)
Expand Down Expand Up @@ -743,8 +743,8 @@ sampled (possibly multiple times) by `sampler`, then complete once both
input producers have completed, or interrupt if either input producer is interrupted.
*/
scopedExample("`sample(with:)`") {
let producer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4 ])
let sampler = SignalProducer<String, NoError>(values: [ "a", "b" ])
let producer = SignalProducer<Int, NoError>([ 1, 2, 3, 4 ])
let sampler = SignalProducer<String, NoError>([ "a", "b" ])

let result = producer.sample(with: sampler)

Expand All @@ -759,7 +759,7 @@ Logs all events that the receiver sends.
By default, it will print to the standard output.
*/
scopedExample("`log events`") {
let baseProducer = SignalProducer<Int, NoError>(values: [ 1, 2, 3, 4, 42 ])
let baseProducer = SignalProducer<Int, NoError>([ 1, 2, 3, 4, 42 ])

baseProducer
.logEvents(identifier: "Playground is fun!")
Expand Down
1 change: 0 additions & 1 deletion ReactiveSwift.playground/contents.xcplayground
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
<page name='Sandbox'/>
<page name='SignalProducer'/>
<page name='Signal'/>
<page name='Property'/>
</pages>
</playground>

0 comments on commit f2d288e

Please sign in to comment.