diff --git a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift index d1a9e0b9..de85eb1b 100644 --- a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift @@ -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