Skip to content

Commit 93f5fb5

Browse files
committed
Update 1. Creating a sequence.md
1 parent 2443048 commit 93f5fb5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Part 2 - Sequence Basics/1. Creating a sequence.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# PART 2 - Sequence basics
22

3-
Now that you understand what Rx is in general, it is time to start creating and manipulating sequences. The original implementation of manipulating sequences was based on C#'s LINQ, which in turn was inspired from functional programming. Knowledge about either isn't necessary, but it would make the learning process a lot easier for the reader. Following the original www.introtorx.com, we too will divide operations into themes that generally go from the simpler to the more advanced. Most Rx operators manipulate existing sequences. But first, we will see how to create an `Observable` to begin with.
3+
Now that you understand what Rx is in general, it is time to start creating and manipulating sequences. The original implementation of manipulating sequences was based on C#'s [LINQ](https://en.wikipedia.org/wiki/Language_Integrated_Query), which in turn was inspired from functional programming. Knowledge about either isn't necessary, but it would make the learning process a lot easier for the reader. Following the original www.introtorx.com, we too will divide operations into themes that generally go from the simpler to the more advanced. Most Rx operators manipulate existing sequences. But first, we will see how to create an `Observable` to begin with.
44

55
# Creating a sequence
66

7-
In previous examples we used `Subject`s and manually pushed values into them to create an sequence. We used that sequence to demonstrate some key concepts and the first and most important Rx method, `subscribe`. In most cases, subjects are not the best way to create a new `Observable`. We will now see tidier ways to create observable sequences.
7+
In previous examples we used `Subject`s and manually pushed values into them to create a sequence. We used that sequence to demonstrate some key concepts and the first and most important Rx method, `subscribe`. In most cases, subjects are not the best way to create a new `Observable`. We will now see tidier ways to create observable sequences.
88

99
## Simple factory methods
1010

@@ -79,7 +79,7 @@ Error: java.lang.Exception: Oops
7979

8080
### Observable.defer
8181

82-
`defer` doesn't define a new kind of observable, but allows you to declare how a source observable should be created every time a subscriber arrives. Consider how you would create an observable that returns the current time and terminates. You are emitting a single value, so it sounds like a case for `just`.
82+
`defer` doesn't define a new kind of observable, but allows you to declare how an observable should be created every time a subscriber arrives. Consider how you would create an observable that returns the current time and terminates. You are emitting a single value, so it sounds like a case for `just`.
8383

8484
```java
8585
Observable<Long> now = Observable.just(System.currentTimeMillis());
@@ -118,7 +118,7 @@ now.subscribe(System.out::println);
118118
static <T> Observable<T> create(Observable.OnSubscribe<T> f)
119119
```
120120

121-
The `Observable.OnSubscribe<T>` is simpler than it looks. It is basically a function that takes an `Subscriber<T>` for type `T`. Inside it we can manually determine the events that are pushed to the subscriber.
121+
The `Observable.OnSubscribe<T>` is simpler than it looks. It is basically a function that takes a `Subscriber<T>` for type `T`. Inside it we can manually determine the events that are pushed to the subscriber.
122122

123123
```java
124124
Observable<String> values = Observable.create(o -> {
@@ -228,7 +228,7 @@ The example above waits 2 seconds, then starts counting every 1 second.
228228

229229
There are well established tools for dealing with sequences, collections and asychronous events, which may not be directly compatible with Rx. Here we will discuss ways to turn their output into input for your Rx code.
230230

231-
If you are using an asynchonous tool that uses event handlers, like JavaFX, you can use `Observable.create` to turn the streams into an observable
231+
If you are using an asynchronous tool that uses event handlers, like JavaFX, you can use `Observable.create` to turn the streams into an observable
232232

233233
```java
234234
Observable<ActionEvent> events = Observable.create(o -> {
@@ -296,7 +296,7 @@ Received: 3
296296
Completed
297297
```
298298

299-
`Observable` is not interchangeable with `Iterable` or `Stream`. `Observable`s are push-based. i.e. the call to `onNext` causes the stack of handlers to execute all the way to the final subscriber method (unless specified otherwise). The other model are pull-based, which means that values are requested as soon as possible and execution blocks until the result is returned.
299+
`Observable` is not interchangeable with `Iterable` or `Stream`. `Observable`s are push-based, i.e., the call to `onNext` causes the stack of handlers to execute all the way to the final subscriber method (unless specified otherwise). The other models are pull-based, which means that values are requested as soon as possible and execution blocks until the result is returned.
300300

301301
#### Continue reading
302302

0 commit comments

Comments
 (0)