determine whether all items emitted by an Observable meet some criteria
all
all
all
every jortSort jortSortUntil
There is also a jortSort
operator that performs a test on the entire sequence of items emitted by the source Observable. If those items are emitted in sorted order, upon the successful completion of the source Observable, the Observable returned from jortSort
will emit true
and then complete. If any of the items emitted by the source Observable is out of sort order, upon the successful completion of the source Observable, the Observable returned from jortSort
will emit false
and then complete.
There is also a jortSortUntil
operator. It does not wait until the source Observable completes to evaluate its sequence for sortedness, as jortSort
does, but waits until a second Observable emits an item to do so.
var source = Rx.Observable.of(1,2,3,4) // already sorted .jortSort(); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (e) { console.log('Error: %s', e); }, function ( ) { console.log('Completed'); });
Next: true Completed
var source = Rx.Observable.of(3,1,2,4) // not sorted .jortSort(); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (e) { console.log('Error: %s', e); }, function ( ) { console.log('Completed'); });
Next: false Completed
var just = Rx.helpers.just; var source = Rx.Observable.of(1,2,3,4) // already sorted .flatmap(function (x) { return Rx.Observable.timer(1000).map(just(x)); }).jortSortUntil(Rx.Observable.timer(3000); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (e) { console.log('Error: %s', e); }, function ( ) { console.log('Completed'); });
Next: true Completed
var just = Rx.helpers.just; var source = Rx.Observable.of(3,1,2,4) // not sorted .flatmap(function (x) { return Rx.Observable.timer(1000).map(just(x)); }).jortSortUntil(Rx.Observable.timer(3000); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (e) { console.log('Error: %s', e); }, function ( ) { console.log('Completed'); });
Next: false Completed
jortSort
and jortSortUntil
are found in the following distribution:
rx.sorting.js
They require one of the following distributions:
rx.js
rx.compat.js
rx.lite.js
rx.lite.compat.js
© ReactiveX contributors
Licensed under the Apache License 2.0.
http://reactivex.io/documentation/operators/all.html