Skip to content

Commit

Permalink
Merge pull request #89 from sleeptillseven/patch-1
Browse files Browse the repository at this point in the history
Format text
  • Loading branch information
Toshinori Minami authored Jan 5, 2017
2 parents 7a73030 + 0aa629a commit baf10b6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ But the best news of all is that you already know how to program like this. Tak
```ruby
# Get evens and square each
someSource
.select {|x| x.even? }
.map {|x| x * x }
.each {|x| puts x.to_s }
.select { |x| x.even? }
.map { |x| x * x }
.each { |x| puts x.to_s }
```

Using RxRuby, you can accomplish the same kind of thing with a push-based collection by changing `each` to `subscribe`.

```ruby
someSource
.select {|x| x.even? }
.map {|x| x * x }
.subscribe {|x| puts x.to_s }
.select { |x| x.even? }
.map { |x| x * x }
.subscribe { |x| puts x.to_s }
```

## Why RxRuby? ##
Expand Down Expand Up @@ -98,8 +98,8 @@ Instead, our goal is to make the Observable module look exactly like the Enumera
So, take an example, zipping two Arrays.

```ruby
a = [ 4, 5, 6 ]
b = [ 7, 8, 9 ]
a = [4, 5, 6]
b = [7, 8, 9]

[1, 2, 3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
[1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]]
Expand All @@ -111,10 +111,10 @@ Now, we could do something similar in [RxRuby](https://github.com/ReactiveX/RxRu
```ruby
require 'rx'

a = Rx::Observable.from_array [ 4, 5, 6 ]
b = Rx::Observable.from_array [ 7, 8, 9 ]
a = Rx::Observable.from_array [4, 5, 6]
b = Rx::Observable.from_array [7, 8, 9]

sub = a.zip(b).subscribe {|arr| puts arr.to_s }
sub = a.zip(b).subscribe { |arr| puts arr.to_s }
# => "[4, 7]"
# => "[5, 8]"
# => "[6, 9]"
Expand Down

0 comments on commit baf10b6

Please sign in to comment.