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
data/examples/defer.rb
CHANGED
data/examples/delay.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using an absolute time to delay by a second
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.range(0, 3)
|
5
5
|
.delay(Time.now + 1)
|
6
6
|
|
7
7
|
subscription = source.subscribe(
|
@@ -25,7 +25,7 @@ while Thread.list.size > 1
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# Using an relatove time to delay by a second
|
28
|
-
source =
|
28
|
+
source = Rx::Observable.range(0, 3)
|
29
29
|
.delay(1)
|
30
30
|
|
31
31
|
subscription = source.subscribe(
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# With subscription_delay
|
4
|
-
source =
|
4
|
+
source = Rx::Observable
|
5
5
|
.range(0, 3)
|
6
6
|
.delay_with_selector(
|
7
|
-
|
7
|
+
Rx::Observable.timer(0.3),
|
8
8
|
lambda {|x|
|
9
|
-
return
|
9
|
+
return Rx::Observable.timer(x * 0.4)
|
10
10
|
}
|
11
11
|
)
|
12
12
|
.time_interval
|
@@ -33,11 +33,11 @@ while Thread.list.size > 1
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Without subscription_delay
|
36
|
-
source =
|
36
|
+
source = Rx::Observable
|
37
37
|
.range(0, 3)
|
38
38
|
.delay_with_selector(
|
39
39
|
lambda {|x|
|
40
|
-
return
|
40
|
+
return Rx::Observable.timer(x * 0.4)
|
41
41
|
})
|
42
42
|
.time_interval
|
43
43
|
.map {|x| x.value.to_s + ':' + x.interval.to_s }
|
data/examples/dematerialize.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
source =
|
3
|
+
source = Rx::Observable
|
4
4
|
.from_array([
|
5
|
-
|
6
|
-
|
5
|
+
Rx::Notification.create_on_next(42),
|
6
|
+
Rx::Notification.create_on_error(Exception.new('woops'))
|
7
7
|
])
|
8
8
|
.dematerialize
|
9
9
|
|
data/examples/disposable.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
disposable =
|
3
|
+
disposable = Rx::Disposable.create {
|
4
4
|
puts 'disposed'
|
5
5
|
}
|
6
6
|
|
7
7
|
disposable.dispose
|
8
8
|
# => disposed
|
9
9
|
|
10
|
-
disposable =
|
10
|
+
disposable = Rx::Disposable.empty
|
11
11
|
|
12
12
|
disposable.dispose # Does nothing
|
data/examples/distinct.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without key selector
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.from_array([
|
5
5
|
42, 24, 42, 24
|
6
6
|
])
|
7
7
|
.distinct
|
@@ -22,7 +22,7 @@ subscription = source.subscribe(
|
|
22
22
|
# => Completed
|
23
23
|
|
24
24
|
# With key selector
|
25
|
-
source =
|
25
|
+
source = Rx::Observable.from_array([
|
26
26
|
{value: 42}, {value: 24}, {value: 42}, {value: 24}
|
27
27
|
])
|
28
28
|
.distinct {|x| x[:value] }
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Without key selector
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.from_array([
|
5
5
|
42, 42, 24, 24
|
6
6
|
])
|
7
7
|
.distinct_until_changed
|
@@ -22,7 +22,7 @@ subscription = source.subscribe(
|
|
22
22
|
# => Completed
|
23
23
|
|
24
24
|
# With key selector
|
25
|
-
source =
|
25
|
+
source = Rx::Observable.from_array([
|
26
26
|
{value: 42}, {value: 42}, {value: 24}, {value: 24}
|
27
27
|
])
|
28
28
|
.distinct_until_changed {|x| x[:value] }
|
data/examples/do.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using a function
|
4
|
-
source =
|
4
|
+
source = Rx::Observable.range(0, 3)
|
5
5
|
.do(
|
6
6
|
lambda {|x| puts 'Do Next:' + x.to_s },
|
7
7
|
lambda {|err| puts 'Do Error:' + err.to_s },
|
@@ -29,13 +29,13 @@ subscription = source.subscribe(
|
|
29
29
|
# => Completed
|
30
30
|
|
31
31
|
# Using an observer
|
32
|
-
observer =
|
32
|
+
observer = Rx::Observer.create(
|
33
33
|
lambda {|x| puts 'Do Next: ' + x.to_s },
|
34
34
|
lambda {|err| puts 'Do Error: ' + err.to_s },
|
35
35
|
lambda { puts 'Do Completed' }
|
36
36
|
)
|
37
37
|
|
38
|
-
source =
|
38
|
+
source = Rx::Observable.range(0, 3)
|
39
39
|
.do(observer)
|
40
40
|
|
41
41
|
subscription = source.subscribe(
|
data/examples/empty.rb
CHANGED
data/examples/for.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using Observables
|
4
4
|
array = [1, 2, 3]
|
5
5
|
|
6
|
-
source =
|
6
|
+
source = Rx::Observable.for(
|
7
7
|
array,
|
8
8
|
lambda {|x|
|
9
|
-
|
9
|
+
Rx::Observable.return(x)
|
10
10
|
})
|
11
11
|
|
12
12
|
subscription = source.subscribe(
|
data/examples/fork_join.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Using observables and Promises
|
4
|
-
source =
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
source = Rx::Observable.fork_join(
|
5
|
+
Rx::Observable.return(42),
|
6
|
+
Rx::Observable.range(0, 10),
|
7
|
+
Rx::Observable.from_array([1,2,3]),
|
8
|
+
Rx::Observable.return(56)
|
9
9
|
)
|
10
10
|
|
11
11
|
subscription = source.subscribe(
|
data/examples/from.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# Array-like object (arguments) to Observable
|
4
4
|
def f(*arguments)
|
5
|
-
|
5
|
+
Rx::Observable.from(arguments)
|
6
6
|
end
|
7
7
|
|
8
8
|
f(1, 2, 3).subscribe(
|
@@ -23,7 +23,7 @@ f(1, 2, 3).subscribe(
|
|
23
23
|
|
24
24
|
# Any iterable object...
|
25
25
|
s = ["foo", :window]
|
26
|
-
|
26
|
+
Rx::Observable.from(s).subscribe(
|
27
27
|
lambda {|x|
|
28
28
|
puts 'Next: ' + x.to_s
|
29
29
|
},
|
@@ -39,7 +39,7 @@ RxRuby::Observable.from(s).subscribe(
|
|
39
39
|
|
40
40
|
# Map
|
41
41
|
m = {1 => 2, 2 => 4, 4 => 8}
|
42
|
-
|
42
|
+
Rx::Observable.from(m).subscribe(
|
43
43
|
lambda {|x|
|
44
44
|
puts 'Next: ' + x.to_s
|
45
45
|
},
|
@@ -55,7 +55,7 @@ RxRuby::Observable.from(m).subscribe(
|
|
55
55
|
# => Completed
|
56
56
|
|
57
57
|
# String
|
58
|
-
|
58
|
+
Rx::Observable.from("foo".to_enum(:each_char)).subscribe(
|
59
59
|
lambda {|x|
|
60
60
|
puts 'Next: ' + x.to_s
|
61
61
|
},
|
@@ -72,7 +72,7 @@ RxRuby::Observable.from("foo".to_enum(:each_char)).subscribe(
|
|
72
72
|
|
73
73
|
# Using an arrow function as the map function to
|
74
74
|
# manipulate the elements
|
75
|
-
|
75
|
+
Rx::Observable.from([1, 2, 3], lambda {|x, i| x + x }).subscribe(
|
76
76
|
lambda {|x|
|
77
77
|
puts 'Next: ' + x.to_s
|
78
78
|
},
|
@@ -88,7 +88,7 @@ RxRuby::Observable.from([1, 2, 3], lambda {|x, i| x + x }).subscribe(
|
|
88
88
|
# => Completed
|
89
89
|
|
90
90
|
# Generate a sequence of numbers
|
91
|
-
|
91
|
+
Rx::Observable.from(5.times, lambda {|v, k| k }).subscribe(
|
92
92
|
lambda {|x|
|
93
93
|
puts 'Next: ' + x.to_s
|
94
94
|
},
|
data/examples/from_array.rb
CHANGED
data/examples/from_callback.rb
CHANGED
data/examples/generate.rb
CHANGED
data/examples/group_join.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
xs =
|
3
|
+
xs = Rx::Observable.interval(0.1)
|
4
4
|
.map {|x| 'first' + x.to_s }
|
5
5
|
|
6
|
-
ys =
|
6
|
+
ys = Rx::Observable.interval(0.1)
|
7
7
|
.map {|x| 'second' + x.to_s }
|
8
8
|
|
9
9
|
source = xs.group_join(
|
10
10
|
ys,
|
11
|
-
lambda {|_| return
|
12
|
-
lambda {|_| return
|
11
|
+
lambda {|_| return Rx::Observable.timer(0) },
|
12
|
+
lambda {|_| return Rx::Observable.timer(0) },
|
13
13
|
lambda {|x, yy|
|
14
14
|
return yy.map {|y|
|
15
15
|
x + y
|
data/examples/if.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
3
|
# This uses and only then source
|
4
4
|
should_run = true
|
5
5
|
|
6
|
-
source =
|
6
|
+
source = Rx::Observable.if(
|
7
7
|
lambda { return should_run },
|
8
|
-
|
8
|
+
Rx::Observable.return(42)
|
9
9
|
)
|
10
10
|
|
11
11
|
subscription = source.subscribe(
|
@@ -25,10 +25,10 @@ subscription = source.subscribe(
|
|
25
25
|
# The next example uses an elseSource
|
26
26
|
should_run = false
|
27
27
|
|
28
|
-
source =
|
28
|
+
source = Rx::Observable.if(
|
29
29
|
lambda { return should_run },
|
30
|
-
|
31
|
-
|
30
|
+
Rx::Observable.return(42),
|
31
|
+
Rx::Observable.return(56)
|
32
32
|
)
|
33
33
|
|
34
34
|
subscription = source.subscribe(
|
data/examples/intervals.rb
CHANGED
data/examples/merge.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
source1 =
|
3
|
+
source1 = Rx::Observable.interval(0.1)
|
4
4
|
.time_interval()
|
5
5
|
.pluck('interval')
|
6
6
|
.take(3)
|
7
|
-
source2 =
|
7
|
+
source2 = Rx::Observable.interval(0.15)
|
8
8
|
.time_interval()
|
9
9
|
.pluck('interval')
|
10
10
|
.take(2)
|
11
11
|
|
12
|
-
source =
|
12
|
+
source = Rx::Observable.merge(
|
13
13
|
source1,
|
14
14
|
source2)
|
15
15
|
|
data/examples/merge_all.rb
CHANGED
data/examples/multicast.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
subject =
|
4
|
-
source =
|
3
|
+
subject = Rx::Subject.new
|
4
|
+
source = Rx::Observable.range(0, 3)
|
5
5
|
.multicast(subject)
|
6
6
|
|
7
|
-
observer =
|
7
|
+
observer = Rx::Observer.create(
|
8
8
|
lambda {|x|
|
9
9
|
puts 'Next: ' + x.to_s
|
10
10
|
},
|
data/examples/never.rb
CHANGED
data/examples/of.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rx'
|
2
2
|
|
3
|
-
source1 =
|
4
|
-
source2 =
|
5
|
-
source3 =
|
3
|
+
source1 = Rx::Observable.raise_error(Exception.new('error 1'))
|
4
|
+
source2 = Rx::Observable.raise_error(Exception.new('error 2'))
|
5
|
+
source3 = Rx::Observable.return(42)
|
6
6
|
|
7
|
-
source =
|
7
|
+
source = Rx::Observable.on_error_resume_next(source1, source2, source3)
|
8
8
|
|
9
9
|
subscription = source.subscribe(
|
10
10
|
lambda {|x|
|
data/examples/pairs.rb
CHANGED