Skip to content

Commit 9181cbc

Browse files
elijahverdoornakarnokd
authored andcommitted
Add generate examples to Creating-Observables.md in Wiki (#6260)
Add documentation and example to the wiki for generate.
1 parent be0353c commit 9181cbc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/Creating-Observables.md

+21
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,27 @@ observable.subscribe(
199199
() -> System.out.println("Done"));
200200
```
201201

202+
## generate
203+
204+
**Available in:** ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Flowable`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Observable`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_off.png) `Maybe`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_off.png) Single`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_off.png) `Completable`
205+
206+
**ReactiveX documentation:** [http://reactivex.io/documentation/operators/create.html](http://reactivex.io/documentation/operators/create.html)
207+
208+
Creates a cold, synchronous and stateful generator of values.
209+
210+
#### generate example:
211+
212+
```java
213+
int startValue = 1;
214+
int incrementValue = 1;
215+
Flowable<Integer> flowable = Flowable.generate(() -> startValue, (s, emitter) -> {
216+
int nextValue = s + incrementValue;
217+
emitter.onNext(nextValue);
218+
return nextValue;
219+
});
220+
flowable.subscribe(value -> System.out.println(value));
221+
```
222+
202223
## create
203224

204225
**Available in:** ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Flowable`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Observable`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Maybe`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Single`, ![image](https://raw.github.com/wiki/ReactiveX/RxJava/images/checkmark_on.png) `Completable`

0 commit comments

Comments
 (0)