rx 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/examples/aggregate.rb +3 -3
- data/examples/amb.rb +4 -4
- data/examples/ambproto.rb +3 -3
- data/examples/and.rb +4 -4
- data/examples/as_observable.rb +2 -2
- data/examples/average.rb +3 -3
- data/examples/buffer_with_count.rb +3 -3
- data/examples/buffer_with_time.rb +3 -3
- data/examples/case.rb +5 -5
- data/examples/catch.rb +4 -4
- data/examples/catchproto.rb +5 -5
- data/examples/combine_latest.rb +4 -4
- data/examples/combine_latestproto.rb +3 -3
- data/examples/concat.rb +4 -4
- data/examples/concat_all.rb +3 -3
- data/examples/concat_map.rb +4 -4
- data/examples/concat_map_observer.rb +5 -5
- data/examples/concatproto.rb +3 -3
- data/examples/connect.rb +3 -3
- data/examples/contains.rb +3 -3
- data/examples/count.rb +3 -3
- data/examples/create.rb +4 -4
- data/examples/debounce.rb +3 -3
- data/examples/default_if_empty.rb +3 -3
- data/examples/defer.rb +3 -3
- data/examples/delay.rb +3 -3
- data/examples/delay_with_selector.rb +6 -6
- data/examples/dematerialize.rb +4 -4
- data/examples/disposable.rb +3 -3
- data/examples/distinct.rb +3 -3
- data/examples/distinct_until_changed.rb +3 -3
- data/examples/do.rb +4 -4
- data/examples/empty.rb +2 -2
- data/examples/for.rb +3 -3
- data/examples/fork_join.rb +6 -6
- data/examples/from.rb +7 -7
- data/examples/from_array.rb +2 -2
- data/examples/from_callback.rb +2 -2
- data/examples/generate.rb +2 -2
- data/examples/group_join.rb +5 -5
- data/examples/if.rb +6 -6
- data/examples/intervals.rb +2 -2
- data/examples/merge.rb +4 -4
- data/examples/merge_all.rb +3 -3
- data/examples/multicast.rb +4 -4
- data/examples/never.rb +2 -2
- data/examples/of.rb +2 -2
- data/examples/on_error_resume_next.rb +5 -5
- data/examples/pairs.rb +2 -2
- data/examples/publish.rb +5 -5
- data/examples/range.rb +2 -2
- data/examples/reduce.rb +2 -2
- data/examples/repeat.rb +2 -2
- data/examples/return.rb +2 -2
- data/examples/scan.rb +3 -3
- data/examples/start.rb +3 -3
- data/examples/throw.rb +3 -3
- data/examples/time_intervals.rb +2 -2
- data/examples/timer.rb +2 -2
- data/examples/timestamp.rb +2 -2
- data/examples/to_a.rb +2 -2
- data/examples/to_async.rb +2 -2
- data/examples/using.rb +3 -3
- data/examples/when.rb +4 -4
- data/examples/while.rb +3 -3
- data/examples/window_with_time.rb +3 -3
- data/examples/zip.rb +3 -3
- data/examples/zip_array.rb +3 -3
- data/lib/core_ext/enumerable.rb +3 -3
- data/lib/{rx_ruby.rb → rx.rb} +11 -11
- data/lib/{rx_ruby → rx}/concurrency/async_lock.rb +1 -1
- data/lib/{rx_ruby → rx}/concurrency/current_thread_scheduler.rb +6 -6
- data/lib/{rx_ruby → rx}/concurrency/default_scheduler.rb +8 -8
- data/lib/{rx_ruby → rx}/concurrency/historical_scheduler.rb +3 -3
- data/lib/{rx_ruby → rx}/concurrency/immediate_scheduler.rb +4 -4
- data/lib/{rx_ruby → rx}/concurrency/local_scheduler.rb +3 -3
- data/lib/{rx_ruby → rx}/concurrency/periodic_scheduler.rb +1 -1
- data/lib/{rx_ruby → rx}/concurrency/scheduled_item.rb +2 -2
- data/lib/{rx_ruby → rx}/concurrency/scheduler.rb +1 -1
- data/lib/{rx_ruby → rx}/concurrency/virtual_time_scheduler.rb +4 -4
- data/lib/{rx_ruby → rx}/core/async_lock_observer.rb +4 -4
- data/lib/{rx_ruby → rx}/core/auto_detach_observer.rb +4 -4
- data/lib/{rx_ruby → rx}/core/checked_observer.rb +2 -2
- data/lib/{rx_ruby → rx}/core/notification.rb +3 -3
- data/lib/{rx_ruby → rx}/core/observable.rb +6 -6
- data/lib/{rx_ruby → rx}/core/observe_on_observer.rb +2 -2
- data/lib/{rx_ruby → rx}/core/observer.rb +1 -1
- data/lib/{rx_ruby → rx}/core/scheduled_observer.rb +3 -3
- data/lib/{rx_ruby → rx}/core/synchronized_observer.rb +3 -3
- data/lib/{rx_ruby → rx}/core/time_interval.rb +1 -1
- data/lib/{rx_ruby → rx}/internal/priority_queue.rb +1 -1
- data/lib/{rx_ruby → rx}/internal/util.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/active_plan.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/join_observer.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/pattern.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/plan.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/connectable_observable.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/_observable_timer_date_and_period.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/_observable_timer_time_span.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/_observable_timer_time_span_and_period.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/aggregate.rb +2 -2
- data/lib/{rx_ruby → rx}/linq/observable/and.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/case.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/concat_all.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/concat_map.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/concat_map_observer.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/contains.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/debounce.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/delay.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/delay_with_selector.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/do.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/for.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/fork_join.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/from.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/group_join.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/if.rb +1 -1
- data/lib/rx/linq/observable/interval.rb +5 -0
- data/lib/{rx_ruby → rx}/linq/observable/multicast.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/of.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/pairs.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/pluck.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/publish.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/start.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/time_interval.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/timer.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/timestamp.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/to_async.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/when.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/while.rb +1 -1
- data/lib/{rx_ruby → rx}/operators/aggregates.rb +31 -31
- data/lib/{rx_ruby → rx}/operators/creation.rb +6 -6
- data/lib/{rx_ruby → rx}/operators/multiple.rb +22 -23
- data/lib/{rx_ruby → rx}/operators/single.rb +14 -14
- data/lib/{rx_ruby → rx}/operators/standard_query_operators.rb +6 -6
- data/lib/{rx_ruby → rx}/operators/synchronization.rb +8 -8
- data/lib/{rx_ruby → rx}/operators/time.rb +12 -12
- data/lib/{rx_ruby → rx}/subjects/async_subject.rb +4 -4
- data/lib/{rx_ruby → rx}/subjects/behavior_subject.rb +3 -3
- data/lib/{rx_ruby → rx}/subjects/replay_subject.rb +5 -5
- data/lib/{rx_ruby → rx}/subjects/subject.rb +4 -4
- data/lib/{rx_ruby → rx}/subjects/subject_extensions.rb +3 -3
- data/lib/{rx_ruby → rx}/subscriptions/composite_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/ref_count_subscription.rb +2 -2
- data/lib/{rx_ruby → rx}/subscriptions/scheduled_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/serial_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/single_assignment_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/testing/cold_observable.rb +4 -4
- data/lib/{rx_ruby → rx}/testing/hot_observable.rb +4 -4
- data/lib/{rx_ruby → rx}/testing/mock_observer.rb +4 -4
- data/lib/{rx_ruby → rx}/testing/reactive_test.rb +3 -3
- data/lib/{rx_ruby → rx}/testing/recorded.rb +1 -1
- data/lib/{rx_ruby → rx}/testing/test_scheduler.rb +8 -8
- data/lib/{rx_ruby → rx}/testing/test_subscription.rb +1 -1
- data/lib/rx/version.rb +3 -0
- data/readme.md +19 -19
- data/{rx_ruby.gemspec → rx.gemspec} +2 -2
- data/test/{rx_ruby → rx}/concurrency/helpers/historical_virtual_scheduler_helper.rb +0 -0
- data/test/{rx_ruby → rx}/concurrency/helpers/immediate_local_scheduler_helper.rb +0 -0
- data/test/{rx_ruby → rx}/concurrency/test_async_lock.rb +1 -1
- data/test/{rx_ruby → rx}/concurrency/test_current_thread_scheduler.rb +3 -3
- data/test/{rx_ruby → rx}/concurrency/test_default_scheduler.rb +1 -1
- data/test/{rx_ruby → rx}/concurrency/test_historical_scheduler.rb +3 -3
- data/test/{rx_ruby → rx}/concurrency/test_immediate_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/concurrency/test_local_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/concurrency/test_periodic_scheduler.rb +1 -1
- data/test/{rx_ruby → rx}/concurrency/test_scheduled_item.rb +4 -4
- data/test/{rx_ruby → rx}/concurrency/test_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/concurrency/test_virtual_time_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/core/test_notification.rb +20 -20
- data/test/{rx_ruby → rx}/core/test_observable_creation.rb +220 -63
- data/test/{rx_ruby → rx}/core/test_observer.rb +39 -39
- data/test/{rx_ruby → rx}/internal/test_priority_queue.rb +6 -6
- data/test/{rx_ruby → rx}/subscriptions/test_composite_subscription.rb +20 -20
- data/test/{rx_ruby → rx}/subscriptions/test_serial_subscription.rb +9 -9
- data/test/{rx_ruby → rx}/subscriptions/test_singleassignment_subscription.rb +8 -8
- data/test/{rx_ruby → rx}/subscriptions/test_subscription.rb +3 -3
- data/test/test_helper.rb +1 -1
- metadata +129 -129
- data/lib/rx_ruby/linq/observable/interval.rb +0 -5
- data/lib/rx_ruby/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f95c760d911eea140a0b60493775fe7867897a2c
|
4
|
+
data.tar.gz: 11f892c743e5c5527fb2b074a3ffb184a486b6f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcbc5062f069e6ffcb10f137112dfe085e5c121c1dd2845fff5bd2e84c16c23880b41b5a71c8df650db7f339b4ae6a1e4f8df0b89a035c61c2d61f575dd72c86
|
7
|
+
data.tar.gz: 076ab5a3cc1942fd5fbd83ab05a98587aca261eab81b5dc3a9cd5c889aa899dcb1ad3e8e735655700b036ef448224a65e2f86764548d6ba7e69a7d192f370583
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/examples/aggregate.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using a seed for the accumulate
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.range(1, 10).aggregate(1) {|acc, x|
|
5
5
|
acc * x
|
6
6
|
}
|
7
7
|
|
@@ -20,7 +20,7 @@ subscription = source.subscribe(
|
|
20
20
|
# => Completed
|
21
21
|
|
22
22
|
# Without a seed
|
23
|
-
source =
|
23
|
+
source = Rx::Observable.range(1, 10).aggregate {|acc, x|
|
24
24
|
acc + x
|
25
25
|
}
|
26
26
|
|
data/examples/amb.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using Observable sequences
|
4
|
-
source =
|
5
|
-
|
6
|
-
|
4
|
+
source = Rx::Observable.amb(
|
5
|
+
Rx::Observable.timer(0.5).map { 'foo' },
|
6
|
+
Rx::Observable.timer(0.2).map { 'bar' }
|
7
7
|
)
|
8
8
|
|
9
9
|
subscription = source.subscribe(
|
data/examples/ambproto.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
first =
|
4
|
-
second =
|
3
|
+
first = Rx::Observable.timer(0.3).map { 'first' }
|
4
|
+
second = Rx::Observable.timer(0.5).map { 'second' }
|
5
5
|
|
6
6
|
source = first.amb(second)
|
7
7
|
|
data/examples/and.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Choice of either plan, the first set of timers or second set
|
4
|
-
source =
|
5
|
-
|
6
|
-
|
4
|
+
source = Rx::Observable.when(
|
5
|
+
Rx::Observable.timer(0.2).and(Rx::Observable.timer(0.3)).then_do(lambda {|x, y| return 'first' }),
|
6
|
+
Rx::Observable.timer(0.4).and(Rx::Observable.timer(0.5)).then_do(lambda {|x, y| return 'second' }),
|
7
7
|
)
|
8
8
|
|
9
9
|
subscription = source.subscribe(
|
data/examples/as_observable.rb
CHANGED
data/examples/average.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without a selector
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.range(0, 9).average
|
5
5
|
|
6
6
|
subscription = source.subscribe(
|
7
7
|
lambda {|x|
|
@@ -24,7 +24,7 @@ arr = [
|
|
24
24
|
{ value: 3 }
|
25
25
|
]
|
26
26
|
|
27
|
-
source =
|
27
|
+
source = Rx::Observable.from_array(arr).average {|x|
|
28
28
|
x[:value]
|
29
29
|
}
|
30
30
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without a skip
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.range(1, 6)
|
5
5
|
.buffer_with_count(2)
|
6
6
|
|
7
7
|
subscription = source.subscribe(
|
@@ -21,7 +21,7 @@ subscription = source.subscribe(
|
|
21
21
|
# => Completed
|
22
22
|
|
23
23
|
# Using a skip
|
24
|
-
source =
|
24
|
+
source = Rx::Observable.range(1, 6)
|
25
25
|
.buffer_with_count(2, 1)
|
26
26
|
|
27
27
|
subscription = source.subscribe(
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without a skip
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.interval(0.1)
|
5
5
|
.buffer_with_time(0.5)
|
6
6
|
.take(3)
|
7
7
|
|
@@ -26,7 +26,7 @@ while Thread.list.size > 1
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Using a skip
|
29
|
-
source =
|
29
|
+
source = Rx::Observable.interval(0.1)
|
30
30
|
.buffer_with_time(0.5, 0.1)
|
31
31
|
.take(3)
|
32
32
|
|
data/examples/case.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
sources = {
|
4
|
-
'foo' =>
|
5
|
-
'bar' =>
|
4
|
+
'foo' => Rx::Observable.return(42),
|
5
|
+
'bar' => Rx::Observable.return(56)
|
6
6
|
}
|
7
7
|
|
8
|
-
defaultSource =
|
8
|
+
defaultSource = Rx::Observable.empty()
|
9
9
|
|
10
|
-
source =
|
10
|
+
source = Rx::Observable.case(
|
11
11
|
lambda {
|
12
12
|
'foo'
|
13
13
|
},
|
data/examples/catch.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
obs1 =
|
4
|
-
obs2 =
|
3
|
+
obs1 = Rx::Observable.raise_error(Exception.new('error'))
|
4
|
+
obs2 = Rx::Observable.return(42)
|
5
5
|
|
6
|
-
source =
|
6
|
+
source = Rx::Observable.rescue_error(obs1, obs2)
|
7
7
|
|
8
8
|
subscription = source.subscribe(
|
9
9
|
lambda {|x|
|
data/examples/catchproto.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using a second observable
|
4
|
-
source =
|
5
|
-
.rescue_error(
|
4
|
+
source = Rx::Observable.raise_error(Exception.new)
|
5
|
+
.rescue_error(Rx::Observable.return(42))
|
6
6
|
|
7
7
|
subscription = source.subscribe(
|
8
8
|
lambda {|x|
|
@@ -19,9 +19,9 @@ subscription = source.subscribe(
|
|
19
19
|
# => Completed
|
20
20
|
|
21
21
|
# Using a handler function
|
22
|
-
source =
|
22
|
+
source = Rx::Observable.raise_error(Exception.new)
|
23
23
|
.rescue_error {|e|
|
24
|
-
|
24
|
+
Rx::Observable.return(e.is_a? Exception)
|
25
25
|
}
|
26
26
|
|
27
27
|
subscription = source.subscribe(
|
data/examples/combine_latest.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Have staggering intervals
|
4
|
-
source1 =
|
4
|
+
source1 = Rx::Observable.interval(0.1)
|
5
5
|
.map {|i| 'First: ' + i.to_s }
|
6
6
|
|
7
|
-
source2 =
|
7
|
+
source2 = Rx::Observable.interval(0.15)
|
8
8
|
.map {|i| 'Second: ' + i.to_s }
|
9
9
|
|
10
10
|
# Combine latest of source1 and source2 whenever either gives a value
|
11
|
-
source =
|
11
|
+
source = Rx::Observable.combine_latest(
|
12
12
|
source1,
|
13
13
|
source2) {|s1, s2| s1.to_s + ', ' + s2.to_s }
|
14
14
|
.take(4)
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Have staggering intervals
|
4
|
-
source1 =
|
4
|
+
source1 = Rx::Observable.interval(0.1)
|
5
5
|
.map {|i| 'First: ' + i.to_s }
|
6
6
|
|
7
|
-
source2 =
|
7
|
+
source2 = Rx::Observable.interval(0.15)
|
8
8
|
.map {|i| 'Second: ' + i.to_s }
|
9
9
|
|
10
10
|
# Combine latest of source1 and source2 whenever either gives a value
|
data/examples/concat.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using Observable sequences
|
4
|
-
source1 =
|
5
|
-
source2 =
|
4
|
+
source1 = Rx::Observable.return(42)
|
5
|
+
source2 = Rx::Observable.return(56)
|
6
6
|
|
7
|
-
source =
|
7
|
+
source = Rx::Observable.concat(source1, source2)
|
8
8
|
|
9
9
|
subscription = source.subscribe(
|
10
10
|
lambda {|x|
|
data/examples/concat_all.rb
CHANGED
data/examples/concat_map.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
source =
|
3
|
+
source = Rx::Observable.range(0, 5)
|
4
4
|
.concat_map(lambda {|x, i|
|
5
|
-
return
|
5
|
+
return Rx::Observable
|
6
6
|
.interval(0.1)
|
7
7
|
.take(x).map { i }
|
8
8
|
})
|
@@ -35,7 +35,7 @@ while Thread.list.size > 1
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Using an array
|
38
|
-
source =
|
38
|
+
source = Rx::Observable.of(1,2,3)
|
39
39
|
.concat_map(
|
40
40
|
lambda {|x, i| return [x,i] },
|
41
41
|
lambda {|x, y, ix, iy| return x + y + ix + iy }
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
source =
|
3
|
+
source = Rx::Observable.range(1, 3)
|
4
4
|
.concat_map_observer(
|
5
5
|
lambda {|x, i|
|
6
|
-
return
|
6
|
+
return Rx::Observable.repeat(x, i)
|
7
7
|
},
|
8
8
|
lambda {|err|
|
9
|
-
return
|
9
|
+
return Rx::Observable.return(42)
|
10
10
|
},
|
11
11
|
lambda {
|
12
|
-
return
|
12
|
+
return Rx::Observable.empty
|
13
13
|
})
|
14
14
|
|
15
15
|
subscription = source.subscribe(
|
data/examples/concatproto.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
source =
|
3
|
+
source = Rx::Observable
|
4
4
|
.return(42)
|
5
|
-
.concat(
|
5
|
+
.concat(Rx::Observable.return(56), Rx::Observable.return(72))
|
6
6
|
|
7
7
|
subscription = source.subscribe(
|
8
8
|
lambda {|x|
|
data/examples/connect.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
interval =
|
3
|
+
interval = Rx::Observable.interval(1)
|
4
4
|
|
5
5
|
source = interval
|
6
6
|
.take(2)
|
7
7
|
.do {|x| puts 'Side effect' }
|
8
8
|
|
9
9
|
def create_observer(tag)
|
10
|
-
return
|
10
|
+
return Rx::Observer.create(
|
11
11
|
lambda {|x|
|
12
12
|
puts 'Next: ' + tag + x.to_s
|
13
13
|
},
|
data/examples/contains.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without an index
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.of(42)
|
5
5
|
.contains(42)
|
6
6
|
|
7
7
|
subscription = source.subscribe(
|
@@ -19,7 +19,7 @@ subscription = source.subscribe(
|
|
19
19
|
# => Completed
|
20
20
|
|
21
21
|
# With an index
|
22
|
-
source =
|
22
|
+
source = Rx::Observable.of(1,2,3)
|
23
23
|
.contains(2, 1)
|
24
24
|
|
25
25
|
subscription = source.subscribe(
|
data/examples/count.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without a predicate
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.range(0, 10).count
|
5
5
|
|
6
6
|
subscription = source.subscribe(
|
7
7
|
lambda {|x|
|
@@ -18,7 +18,7 @@ subscription = source.subscribe(
|
|
18
18
|
# => Completed
|
19
19
|
|
20
20
|
# With a predicate
|
21
|
-
source =
|
21
|
+
source = Rx::Observable.range(0, 10)
|
22
22
|
.count {|x| x % 2 === 0 }
|
23
23
|
|
24
24
|
subscription = source.subscribe(
|
data/examples/create.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using a function
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.create {|observer|
|
5
5
|
observer.on_next(42)
|
6
6
|
observer.on_completed
|
7
7
|
|
@@ -30,12 +30,12 @@ subscription.dispose
|
|
30
30
|
# => disposed
|
31
31
|
|
32
32
|
# Using a disposable
|
33
|
-
source =
|
33
|
+
source = Rx::Observable.create {|observer|
|
34
34
|
observer.on_next(42)
|
35
35
|
observer.on_completed
|
36
36
|
|
37
37
|
# Note that this is optional, you do not have to return this if you require no cleanup
|
38
|
-
|
38
|
+
Rx::Disposable.create {
|
39
39
|
puts 'disposed'
|
40
40
|
}
|
41
41
|
}
|
data/examples/debounce.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
times = [
|
4
4
|
{ value: 0, time: 0.1 },
|
@@ -9,9 +9,9 @@ times = [
|
|
9
9
|
]
|
10
10
|
|
11
11
|
# Delay each item by time and project value
|
12
|
-
source =
|
12
|
+
source = Rx::Observable.from(times)
|
13
13
|
.flat_map {|item|
|
14
|
-
|
14
|
+
Rx::Observable.of(item[:value])
|
15
15
|
.delay(item[:time])
|
16
16
|
}
|
17
17
|
.debounce 0.5 # ms
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without a default value
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.empty.default_if_empty
|
5
5
|
|
6
6
|
subscription = source.subscribe(
|
7
7
|
lambda {|x|
|
@@ -18,7 +18,7 @@ subscription = source.subscribe(
|
|
18
18
|
# => Completed
|
19
19
|
|
20
20
|
# With a default_value
|
21
|
-
source =
|
21
|
+
source = Rx::Observable.empty.default_if_empty(false)
|
22
22
|
|
23
23
|
subscription = source.subscribe(
|
24
24
|
lambda {|x|
|