Add generate example to playground

This commit is contained in:
Jorge Bernal 2016-01-21 07:55:22 +01:00
parent a3afac7428
commit 1e9a14a230
1 changed files with 19 additions and 0 deletions

View File

@ -111,6 +111,25 @@ example("create") {
}
}
/*:
### generate
`generate` creates sequence that generates its values and determines when to terminate based on its previous values.
*/
example("generate") {
let generated = Observable.generate(
initialState: 0,
condition: { $0 < 3 },
iterate: { $0 + 1 }
)
let subscription = generated
.subscribe { event in
print(event)
}
}
/*:
### failWith
create an Observable that emits no items and terminates with an error