rx 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,18 +1,18 @@
|
|
1
1
|
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
2
2
|
|
3
3
|
require 'thread'
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
4
|
+
require 'rx/subscriptions/composite_subscription'
|
5
|
+
require 'rx/core/observer'
|
6
|
+
require 'rx/core/observable'
|
7
|
+
require 'rx/operators/single'
|
8
|
+
require 'rx/operators/standard_query_operators'
|
9
9
|
|
10
|
-
module
|
10
|
+
module Rx
|
11
11
|
|
12
12
|
module Observable
|
13
13
|
|
14
14
|
# Internal method to get the final value
|
15
|
-
# @return [
|
15
|
+
# @return [Rx::Observable]
|
16
16
|
def final
|
17
17
|
AnonymousObservable.new do |observer|
|
18
18
|
value = nil
|
@@ -42,8 +42,8 @@ module RxRuby
|
|
42
42
|
|
43
43
|
# Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single
|
44
44
|
# element in the result sequence. The specified seed value is used as the initial accumulator value.
|
45
|
-
# For aggregation behavior with incremental intermediate results, see
|
46
|
-
# @return [
|
45
|
+
# For aggregation behavior with incremental intermediate results, see Rx::Observable.scan
|
46
|
+
# @return [Rx::Observable]
|
47
47
|
def reduce(*args, &block)
|
48
48
|
# Argument parsing to support:
|
49
49
|
# 1. (seed, Symbol) || (seed, &block)
|
@@ -60,7 +60,7 @@ module RxRuby
|
|
60
60
|
# Determines whether all elements of an observable sequence satisfy a condition if block given, else if all are
|
61
61
|
# true
|
62
62
|
# @param [Proc] block
|
63
|
-
# @return [
|
63
|
+
# @return [Rx::Observable]
|
64
64
|
def all?(&block)
|
65
65
|
block ||= lambda { |_| true }
|
66
66
|
select {|v| !(block.call v)}.
|
@@ -71,7 +71,7 @@ module RxRuby
|
|
71
71
|
# Determines whether no elements of an observable sequence satisfy a condition if block given, else if all are
|
72
72
|
# false
|
73
73
|
# @param [Proc] block
|
74
|
-
# @return [
|
74
|
+
# @return [Rx::Observable]
|
75
75
|
def none?(&block)
|
76
76
|
block ||= lambda { |_| true }
|
77
77
|
select {|v| !(block.call v)}.
|
@@ -80,7 +80,7 @@ module RxRuby
|
|
80
80
|
|
81
81
|
# Determines whether any element of an observable sequence satisfies a condition if a block is given else if
|
82
82
|
# there are any items in the observable sequence.
|
83
|
-
# @return [
|
83
|
+
# @return [Rx::Observable]
|
84
84
|
def any?(&block)
|
85
85
|
return map(&block).any? if block_given?
|
86
86
|
AnonymousObservable.new do |observer|
|
@@ -105,7 +105,7 @@ module RxRuby
|
|
105
105
|
# Computes the average of an observable sequence of values that are optionally obtained by invoking a
|
106
106
|
# transform function on each element of the input sequence if a block is given
|
107
107
|
# @param [Object] block
|
108
|
-
# @return [
|
108
|
+
# @return [Rx::Observable]
|
109
109
|
def average(&block)
|
110
110
|
return map(&block).average if block_given?
|
111
111
|
scan({:sum => 0, :count => 0}) {|prev, current| {:sum => prev[:sum] + current, :count => prev[:count] + 1 }}.
|
@@ -118,7 +118,7 @@ module RxRuby
|
|
118
118
|
|
119
119
|
# Determines whether an observable sequence contains a specified element.
|
120
120
|
# @param [Object] item The value to locate in the source sequence.
|
121
|
-
# @return [
|
121
|
+
# @return [Rx::Observable] An observable sequence containing a single element determining whether the source
|
122
122
|
# sequence contains an element that has the specified value.
|
123
123
|
def contains?(item)
|
124
124
|
select {|x| x.eql? item}.any?
|
@@ -134,7 +134,7 @@ module RxRuby
|
|
134
134
|
|
135
135
|
# Returns the element at a specified index in a sequence.
|
136
136
|
# @param [Numeric] index The zero-based index of the element to retrieve.
|
137
|
-
# @return [
|
137
|
+
# @return [Rx::Observable] An observable sequence that produces the element at the specified position in the
|
138
138
|
# source sequence.
|
139
139
|
def element_at(index)
|
140
140
|
raise ArgumentError.new 'index cannot be less than zero' if index < 0
|
@@ -190,7 +190,7 @@ module RxRuby
|
|
190
190
|
# Returns the first element of an observable sequence that satisfies the condition in the predicate if a block is
|
191
191
|
# given, else the first item in the observable sequence.
|
192
192
|
# @param [Proc] block Optional predicate function to evaluate for elements in the source sequence.
|
193
|
-
# @return [
|
193
|
+
# @return [Rx::Observable] Sequence containing the first element in the observable sequence that satisfies the
|
194
194
|
# condition in the predicate if a block is given, else the first element.
|
195
195
|
def first(&block)
|
196
196
|
return select(&block).first if block_given?
|
@@ -213,7 +213,7 @@ module RxRuby
|
|
213
213
|
# or a default value if no such element exists.
|
214
214
|
# @param [Object] default_value The default value to use if the sequence is empty.
|
215
215
|
# @param [Proc] block An optional predicate function to evaluate for elements in the source sequence.
|
216
|
-
# @return [
|
216
|
+
# @return [Rx::Observable] Sequence containing the first element in the observable sequence that satisfies the
|
217
217
|
# condition in the predicate if given, or a default value if no such element exists.
|
218
218
|
def first_or_default(default_value = nil, &block)
|
219
219
|
return select(&block).first_or_default(default_value) if block_given?
|
@@ -237,7 +237,7 @@ module RxRuby
|
|
237
237
|
end
|
238
238
|
|
239
239
|
# Determines whether an observable sequence is empty.
|
240
|
-
# @return [
|
240
|
+
# @return [Rx::Observable] An observable sequence containing a single element determining whether the source
|
241
241
|
# sequence is empty.
|
242
242
|
def empty?
|
243
243
|
any?.map {|b| !b }
|
@@ -246,7 +246,7 @@ module RxRuby
|
|
246
246
|
# Returns the last element of an observable sequence that satisfies the condition in the predicate if the block is
|
247
247
|
# given, else the last element in the observable sequence.
|
248
248
|
# @param [Proc] block An predicate function to evaluate for elements in the source sequence.
|
249
|
-
# @return {
|
249
|
+
# @return {Rx::Observable} Sequence containing the last element in the observable sequence that satisfies the
|
250
250
|
# condition in the predicate if given, or the last element in the observable sequence.
|
251
251
|
def last(&block)
|
252
252
|
return select(&block).last if block_given?
|
@@ -281,7 +281,7 @@ module RxRuby
|
|
281
281
|
# a default value if no such element exists.
|
282
282
|
# @param [Object] default_value The default value to use if the sequence is empty.
|
283
283
|
# @param [Proc] block An predicate function to evaluate for elements in the source sequence.
|
284
|
-
# @return {
|
284
|
+
# @return {Rx::Observable} Sequence containing the last element in the observable sequence that satisfies the
|
285
285
|
# condition in the predicate if given, or a default value if no such element exists.
|
286
286
|
def last_or_default(default_value = nil, &block)
|
287
287
|
return select(&block).last_or_default(default_value) if block_given?
|
@@ -310,7 +310,7 @@ module RxRuby
|
|
310
310
|
|
311
311
|
# Returns the maximum element in an observable sequence.
|
312
312
|
# @param [Proc] block An optional selector function to produce an element.
|
313
|
-
# @return [
|
313
|
+
# @return [Rx::Observable] The maximum element in an observable sequence.
|
314
314
|
def max(&block)
|
315
315
|
return map(&block).max if block_given?
|
316
316
|
max_by {x| x} .map {|x| x[0] }
|
@@ -318,7 +318,7 @@ module RxRuby
|
|
318
318
|
|
319
319
|
# Returns the elements in an observable sequence with the maximum key value.
|
320
320
|
# @param [Proc] block Key selector function.
|
321
|
-
# @return [
|
321
|
+
# @return [Rx::Observable] An observable sequence containing a list of zero or more elements that have a maximum
|
322
322
|
# key value.
|
323
323
|
def max_by(&block)
|
324
324
|
extrema_by(&block)
|
@@ -326,7 +326,7 @@ module RxRuby
|
|
326
326
|
|
327
327
|
# Returns the minimum element in an observable sequence.
|
328
328
|
# @param [Proc] block An optional selector function to produce an element.
|
329
|
-
# @return [
|
329
|
+
# @return [Rx::Observable] The minimum element in an observable sequence.
|
330
330
|
def min(&block)
|
331
331
|
return map(&block).min if block_given?
|
332
332
|
min_by {|x| x} .map {|x| x[0] }
|
@@ -334,15 +334,15 @@ module RxRuby
|
|
334
334
|
|
335
335
|
# Returns the elements in an observable sequence with the minimum key value.
|
336
336
|
# @param [Proc] block Key selector function.
|
337
|
-
# @return [
|
337
|
+
# @return [Rx::Observable] >An observable sequence containing a list of zero or more elements that have a
|
338
338
|
# minimum key value.
|
339
339
|
def min_by(&block)
|
340
340
|
extrema_by(true, &block)
|
341
341
|
end
|
342
342
|
|
343
343
|
# Determines whether two sequences are equal by comparing the elements pairwise.
|
344
|
-
# @param [
|
345
|
-
# @return [
|
344
|
+
# @param [Rx::Observable] other Other observable sequence to compare.
|
345
|
+
# @return [Rx::Observable] An observable sequence that contains a single element which indicates whether both
|
346
346
|
# sequences are of equal length and their corresponding elements are equal.
|
347
347
|
def sequence_eql?(other)
|
348
348
|
AnonymousObservable.new do |observer|
|
@@ -439,7 +439,7 @@ module RxRuby
|
|
439
439
|
# Returns the only element of an observable sequence, and reports an exception if there is not exactly one
|
440
440
|
# element in the observable sequence.
|
441
441
|
# @param [Proc] block A predicate function to evaluate for elements in the source sequence.
|
442
|
-
# @return [
|
442
|
+
# @return [Rx::Observable] >Sequence containing the single element in the observable sequence.
|
443
443
|
def single(&block)
|
444
444
|
return select(&block).single if block_given?
|
445
445
|
AnonymousObservable.new do |observer|
|
@@ -476,7 +476,7 @@ module RxRuby
|
|
476
476
|
# this method reports an exception if there is more than one element in the observable sequence.
|
477
477
|
# @param [Object] default_value The default value if no value is provided
|
478
478
|
# @param [Proc] block A predicate function to evaluate for elements in the source sequence.
|
479
|
-
# @return [
|
479
|
+
# @return [Rx::Observable] Sequence containing the single element in the observable sequence, or a default value
|
480
480
|
# if no such element exists.
|
481
481
|
def single_or_default(default_value = nil, &block)
|
482
482
|
return select(&block).single_or_default(default_value) if block_given?
|
@@ -508,7 +508,7 @@ module RxRuby
|
|
508
508
|
|
509
509
|
# Computes the sum of a sequence of values.
|
510
510
|
# @param [Proc] block Optional block used to obtain the value to sum.
|
511
|
-
# @return [
|
511
|
+
# @return [Rx::Observable] An observable sequence containing a single element with the sum of the values in the
|
512
512
|
# source sequence.
|
513
513
|
def sum(&block)
|
514
514
|
return map(&block).sum if block_given?
|
@@ -516,7 +516,7 @@ module RxRuby
|
|
516
516
|
end
|
517
517
|
|
518
518
|
# Creates an array from an observable sequence.
|
519
|
-
# @return [
|
519
|
+
# @return [Rx::Observable] An array created from an observable sequence.
|
520
520
|
def to_a
|
521
521
|
AnonymousObservable.new do |observer|
|
522
522
|
arr = []
|
@@ -550,7 +550,7 @@ module RxRuby
|
|
550
550
|
end
|
551
551
|
|
552
552
|
# Creates a Hash from the observable collection. Note that any duplicate keys will be overwritten.
|
553
|
-
# @return [
|
553
|
+
# @return [Rx::Observable] A Hash created from an observable sequence.
|
554
554
|
def to_h
|
555
555
|
h = HashConfiguration.new
|
556
556
|
yield h if block_given?
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
3
|
+
require 'rx/concurrency/current_thread_scheduler'
|
4
|
+
require 'rx/concurrency/immediate_scheduler'
|
5
|
+
require 'rx/subscriptions/composite_subscription'
|
6
|
+
require 'rx/subscriptions/subscription'
|
7
7
|
|
8
|
-
module
|
8
|
+
module Rx
|
9
9
|
|
10
10
|
module Observable
|
11
11
|
|
@@ -76,7 +76,7 @@ module RxRuby
|
|
76
76
|
end
|
77
77
|
rescue => err
|
78
78
|
observer.on_error err
|
79
|
-
|
79
|
+
break
|
80
80
|
end
|
81
81
|
if has_result
|
82
82
|
observer.on_next result
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
2
2
|
|
3
3
|
require 'monitor'
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
4
|
+
require 'rx/concurrency/async_lock'
|
5
|
+
require 'rx/subscriptions/subscription'
|
6
|
+
require 'rx/subscriptions/composite_subscription'
|
7
|
+
require 'rx/subscriptions/ref_count_subscription'
|
8
|
+
require 'rx/subscriptions/single_assignment_subscription'
|
9
|
+
require 'rx/core/observer'
|
10
|
+
require 'rx/core/observable'
|
11
|
+
require 'rx/operators/creation'
|
12
12
|
|
13
|
-
module
|
13
|
+
module Rx
|
14
14
|
|
15
15
|
module Observable
|
16
16
|
|
@@ -141,7 +141,7 @@ module RxRuby
|
|
141
141
|
res = result_selector.call left, right
|
142
142
|
rescue => e
|
143
143
|
observer.on_error e
|
144
|
-
|
144
|
+
break
|
145
145
|
end
|
146
146
|
observer.on_next res
|
147
147
|
end
|
@@ -168,7 +168,7 @@ module RxRuby
|
|
168
168
|
res = result_selector.call left, right
|
169
169
|
rescue => e
|
170
170
|
observer.on_error e
|
171
|
-
|
171
|
+
break
|
172
172
|
end
|
173
173
|
observer.on_next res
|
174
174
|
end
|
@@ -443,7 +443,7 @@ module RxRuby
|
|
443
443
|
error = nil
|
444
444
|
|
445
445
|
if disposed
|
446
|
-
|
446
|
+
break
|
447
447
|
else
|
448
448
|
begin
|
449
449
|
current = e.next
|
@@ -457,7 +457,7 @@ module RxRuby
|
|
457
457
|
|
458
458
|
if error
|
459
459
|
observer.on_error error
|
460
|
-
|
460
|
+
break
|
461
461
|
end
|
462
462
|
|
463
463
|
unless has_next
|
@@ -466,7 +466,7 @@ module RxRuby
|
|
466
466
|
else
|
467
467
|
observer.on_completed
|
468
468
|
end
|
469
|
-
|
469
|
+
break
|
470
470
|
end
|
471
471
|
|
472
472
|
new_obs = Observer.configure do |o|
|
@@ -510,13 +510,13 @@ module RxRuby
|
|
510
510
|
res = result_selector.call(*values)
|
511
511
|
rescue => e
|
512
512
|
observer.on_error e
|
513
|
-
|
513
|
+
break
|
514
514
|
end
|
515
515
|
|
516
516
|
observer.on_next(res)
|
517
517
|
elsif enumerable_select_with_index(is_done) {|_, j| j != i} .all?
|
518
518
|
observer.on_completed
|
519
|
-
|
519
|
+
break
|
520
520
|
end
|
521
521
|
end
|
522
522
|
|
@@ -564,7 +564,7 @@ module RxRuby
|
|
564
564
|
err = nil
|
565
565
|
|
566
566
|
if disposed
|
567
|
-
|
567
|
+
break
|
568
568
|
else
|
569
569
|
begin
|
570
570
|
current = e.next
|
@@ -578,12 +578,12 @@ module RxRuby
|
|
578
578
|
|
579
579
|
if err
|
580
580
|
observer.on_error err
|
581
|
-
|
581
|
+
break
|
582
582
|
end
|
583
583
|
|
584
584
|
unless has_next
|
585
585
|
observer.on_completed
|
586
|
-
|
586
|
+
break
|
587
587
|
end
|
588
588
|
|
589
589
|
d = SingleAssignmentSubscription.new
|
@@ -631,7 +631,6 @@ module RxRuby
|
|
631
631
|
current = nil
|
632
632
|
has_next = false
|
633
633
|
err = nil
|
634
|
-
|
635
634
|
if !disposed
|
636
635
|
begin
|
637
636
|
current = e.next
|
@@ -642,17 +641,17 @@ module RxRuby
|
|
642
641
|
err = e
|
643
642
|
end
|
644
643
|
else
|
645
|
-
|
644
|
+
break
|
646
645
|
end
|
647
646
|
|
648
647
|
if err
|
649
648
|
observer.on_error err
|
650
|
-
|
649
|
+
break
|
651
650
|
end
|
652
651
|
|
653
652
|
unless has_next
|
654
653
|
observer.on_completed
|
655
|
-
|
654
|
+
break
|
656
655
|
end
|
657
656
|
|
658
657
|
d = SingleAssignmentSubscription.new
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
3
|
+
require 'rx/subscriptions/subscription'
|
4
|
+
require 'rx/subscriptions/composite_subscription'
|
5
|
+
require 'rx/subscriptions/ref_count_subscription'
|
6
|
+
require 'rx/subscriptions/single_assignment_subscription'
|
7
|
+
require 'rx/core/observer'
|
8
|
+
require 'rx/core/observable'
|
9
|
+
require 'rx/operators/creation'
|
10
10
|
|
11
|
-
module
|
11
|
+
module Rx
|
12
12
|
|
13
13
|
module Observable
|
14
14
|
|
@@ -28,7 +28,7 @@ module RxRuby
|
|
28
28
|
def dematerialize
|
29
29
|
AnonymousObservable.new do |observer|
|
30
30
|
|
31
|
-
new_obs =
|
31
|
+
new_obs = Rx::Observer.configure do |o|
|
32
32
|
o.on_next {|x| x.accept observer }
|
33
33
|
o.on_error(&observer.method(:on_error))
|
34
34
|
o.on_completed(&observer.method(:on_completed))
|
@@ -45,7 +45,7 @@ module RxRuby
|
|
45
45
|
current_key = nil
|
46
46
|
has_current = nil
|
47
47
|
|
48
|
-
new_obs =
|
48
|
+
new_obs = Rx::Observer.configure do |o|
|
49
49
|
o.on_next do |value|
|
50
50
|
key = nil
|
51
51
|
begin
|
@@ -75,7 +75,7 @@ module RxRuby
|
|
75
75
|
def tap(observer)
|
76
76
|
raise ArgumentError.new 'Observer cannot be nil' unless observer
|
77
77
|
AnonymousObservable.new do |obs|
|
78
|
-
new_obs =
|
78
|
+
new_obs = Rx::Observer.configure do |o|
|
79
79
|
|
80
80
|
o.on_next do |value|
|
81
81
|
begin
|
@@ -130,7 +130,7 @@ module RxRuby
|
|
130
130
|
# Ignores all elements in an observable sequence leaving only the termination messages.
|
131
131
|
def ignore_elements
|
132
132
|
AnonymousObservable.new do |observer|
|
133
|
-
new_obs =
|
133
|
+
new_obs = Rx::Observer.configure do |o|
|
134
134
|
o.on_next {|_| }
|
135
135
|
o.on_error(&observer.method(:on_error))
|
136
136
|
o.on_completed(&observer.method(:on_completed))
|
@@ -143,7 +143,7 @@ module RxRuby
|
|
143
143
|
# Materializes the implicit notifications of an observable sequence as explicit notification values.
|
144
144
|
def materialize
|
145
145
|
AnonymousObservable.new do |observer|
|
146
|
-
new_obs =
|
146
|
+
new_obs = Rx::Observer.configure do |o|
|
147
147
|
|
148
148
|
o.on_next {|x| observer.on_next(Notification.create_on_next x) }
|
149
149
|
|
@@ -230,7 +230,7 @@ module RxRuby
|
|
230
230
|
end
|
231
231
|
rescue => err
|
232
232
|
observer.on_error err
|
233
|
-
|
233
|
+
break
|
234
234
|
end
|
235
235
|
|
236
236
|
observer.on_next accumulation
|