RxJS implements this operator as every
. The following example shows how to use this operator:
var source = Rx.Observable.of(1,2,3,4,5) .every(function (x) { return x < 6; }); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (err) { console.log('Error: %s', err); }, function () { console.log('Completed'); });
Next: true Completed
every
is found in the following distributions:
rx.all.js
rx.all.compat.js
rx.aggregates.js
It requires one of the following distributions:
rx.js
rx.compat.js
rx.lite.js
rx.lite.compat.js
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'); });
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'); });
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'); });
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'); });
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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4