Note that these removals are mostly motivated by reducing the amount of code to write tests for; we may well want to introduce them again later.
- Remove
Observable.subscribe_on_next/error/completedas they are problematic in that it is not clear that you can only use one of them. - Remove
ObserveOnObserverand make its superclassScheduledObsevertake its role; they did not have a clean separation of concerns. - Remove
Observer.create; having a specific method for triple-lambda is not worth the confusion; useObserver.configureinstead. - Remove stub
ReplaySubjectuntil it can be properly implemented. - Remove
.containswhich duplicates.contains? - Remove
.disposeon subscriptions. While the name dispose/disposable might be more distinct, the codebase is dominated by subscribe/unsubscribe/subscription. - Remove
.element_at_or_default,.first_or_default,.last_or_default,.single_or_defaultoperators and equip.element_at,.first,.last,.singlewith optional default value parameters. - Remove
.min_byand.max_by. These are inspired by Ruby where they add convenience over.min/.maxby allowing you to pick the to compare, but unlike Ruby's return lists. They seem to have no equivalent in other modern ReactiveX implementations. - Remove
.pairswhich is not correctly implemented; try.buffer_with_count(2). - Remove
.take_last_buffer. Use.take_last(n).to_ainstead; this method is no longer in RxJS 5 either. - Remove
.tapas an alias of.do;.tapis a Ruby object builtin and quite useful on Observables in some cases. - Remove
.when,.andoperators because of the extensive testing/fixing needed; try.fork_joinor.zipinstead.
.delay_with_selectornow accepts a block as selector rather than a lambda..distinct_until_changednow accepts a comparator function, using<=>for default..ifno longer takes a scheduler to pass to empty else arguments; if you really need to pass the completion on a separate scheduler you will have to pass your own.empty..minand.maxnow takes a block that will get two arguments comparator-style and is expected to return -1, 0 or 1 much as<=>(which is the default comparator)..timestampnow emits structs rather than hash values to reduce risk of confusion with processed values.- Drop support for Ruby 1.8.
BehaviorSubjectnow handleson_error,on_completed.ConnectableObservable.ref_countcounts references properly and unsubscribes on last..any?now applies block with.selectrather than.mapas.mapwill always emit, making.any?return true regardless of input..average,.sumgenerates detailed exceptions on non-numerical input..concatnow unsubscribes sources when they are exhausted.DefaultSchedulerscheduling actions previously didThread#exiton unsubscribe. However, where the scheduling call (e.g.subscribe_on) occurs in the middle of a chain, we do not actually know that the thread is done when the scheduling subscriptionunsubscribemethod is triggered (e.g. byAutoDetachObserver). This resulted in operations like.merge_alland.merge_concurrentthat lack rigid connection between upstream and downstream subscriptions would work fine in synchronous operation, but the stream would mysteriously die when put onDefaultScheduler. Given thatThread.exiton a worker thread with a finite lifecycle is a dubious concept at the best of times, this PR simply removes the composite subscription and passes out aSingleAssignmentSubscriptioninstead..delaynow propagates errors immediately..distinct_until_changednow treatsnilas an ordinary value..first,.element_atnow on_errors rather than raise on "sequence contains no elements"..fork_joinavoids lambda return which fails on older Ruby..group_joinnow emits right-hand values on left-hand subjects..group_joinright duration exceptions now inform subjects..latestnow unsubscribes inner observables..latestnow completes only when both outer and inner observable has completed..materializenow emits errors ason_errornotifications (rather thanon_nextnotifications).mergenow propagates unsubscribes to inner observables..merge_concurrentnow propagates unsubscribes to inner observables..multicastsubscribes properly to its connectable..none?now.selectaccording to block (rather than block negation; since.any?is fail-fast) and then map-invert the result (like.all?).- Recursively scheduled items now produce proper subscriptions so that they can be cancelled.
.rescue_erroractually tries left observable (i.e. self) before trying alternate observable..samplenow respectsnilvalues..samplepropagates recipe exceptions properly..scanoperator use next instead of break.ScheduledObserverpasses error to wrapped observer or it is very likely to "disappear" since we are very likely to be on a thread..sequence_eql?now unsubscribes completed sequences immediately, rather than when the slowest sequence completes..skip_untilnow completes if upstream completed without emission..skip_while,.skip_while_with_indexnow continue emitting values after they stop skipping..take_lastnow emits the correct number of items, rather than always emitting zero values..to_hnow uses value selector properly..window_with_timenow unsubscribes properly..zipneeds to catch errors in result selector.- New, thread-aware Enumerator implementation used by
.concat,.repeat_infinitelyand others. RxRuby was using Ruby Enumerator for as an internal short-hand for repeating an Observable a fixed or infinite number of times, for example the.repeat_infinitelyoperator. The problem with this is that MRI's Enumerator is explicitly thread-averse, as is described in #4 and #10. This affects all places where one part of RxRuby is passing an Enumerator to another part, since the caller cannot know if the receiving observable will be executed across more than one thread.
- Remove instance version of
.combine_latestin favour of delegating to class-level.combine_latest. - Remove internally unused time-math methods from test scheduler.
.debounceraises argument error on negative numbers.- Implement time-based
.timer. CurrentThreadScheduleruses a thread-local queue rather than a class member queue.CurrentThreadScheduleris a singleton and can refer to instance members rather than class methods.- Properly synchronise
.delayoperator. - Reimplement
.merge_allas.merge_concurrentwith infinite concurrency since the latter is properly synchronised. - Shared scheduler tests no longer delays test execution ~6 seconds; MRI now executes tests in about 2 seconds.
.multicastdefaults to transparent selector so you don't have to give two arguments..publishblock is now properly optional..multicastdoes not accept selector when passed a single subject.ConnectableObservable.ref_countnow raises when it has already been.connect:ed..skip,.takenow throwsArgumentErroron negative count.- reimplement
.window_with_timefor better readability and properly managed subscriptions. Also fixes the issue that the first window goes first when scheduled on test scheduler, while subsequent windows go after value emission in a particular time slot; an issue since the marble tests don't increment time by 1 for "simultaneous" events. - subscribing to disposed
Subjects yieldsRuntimeError. AsycSubject,BehaviorSubject,Subjectdelegate subscribing toObservable.subscribe.- clarify that instance
.rescue_errorwon't accept both alternate observable and block. .merge_concurrentvalidates that max_concurrency is integer..merge_concurrentclass version can now be called without scheduler argument as intended..zipshould complete as soon as there is no chance of another pair, i.e. when one source has been exhausted and has completed..forblock is a "transform", rather than a "result selector".- ensure argument to
.repeatis an integer. Rx::Subjectallows the normal subscription styles thatObservable.subscribeuses - it is an Observable, after all. This PR simply uses thesubscribemethod fromRx::Observableto normalise the observer setup and instead overrides_subscribe. This also fixes a bug where.to_aassumed that you could use the three-lambda subscription form on itself: https://github.com/bittrance/rxruby/blob/caea16f7e723e8ea6f2241210abae5009b1827c6/lib/rx/operators/aggregates.rb#L523..dono longer requires all three lambdas to be supplied. Despite defaulting its first argument tonil,.dounhelpfully threw nil-class errors on e.g..do(nil, lambda {|e| ... }, lambda { ... }).