rx-js-extras
A few RxJS extension methods to make working with Observables easier.
var _ = ;var Rx = ; var observableProto = RxObservableprototype; // // Combine from both sources until either source completes.// observableProto {}; // // Combine from both sources until the source Observable completes.// observableProto {}; // // Combine from both sources until the second Observable completes.// observableProto {}; // // Combines both sources into a Tuple[a, b]// observableProtocombinePair =observableProtocombineTuple = observableProtocombineAsPair =observableProto {}; // // Combines both sources into a Tuple[a, b] until either source completes.// observableProtocombinePairUntil =observableProtocombineTupleUntil =observableProtocombineAsPairUntil =observableProto {}; // // Combines both sources into a Tuple[a, b] until the source Observable completes.// observableProtocombinePairUntilFirst =observableProtocombineTupleUntilFirst =observableProtocombineAsPairUntilFirst =observableProto {}; // // Combines both sources into a Tuple[a, b] until the second Observable completes.// observableProtocombinePairUntilSecond =observableProtocombineTupleUntilSecond =observableProtocombineAsPairUntilSecond =observableProto {}; // // Combines both sources, but only takes values from the source Observable.// observableProtocombineFirst =observableProto {}; // // Combines both sources, but only takes values from the second Observable.// observableProtocombineSecond =observableProto {}; // // Combines both sources, merging the results into a// variable-length Array of values. For example, if// each source dispatches a Tuple[a, b], `combineMultiple`// will dispatch an Array of 4 values, [a1, b1, a2, b2].// observableProtocombineAll = observableProtocombineMerge = observableProto {}; // // Scans the source values into an Array.// observableProtoasList =observableProtoasArray =observableProto {}; // // Scans the source values into an Array with Array.prototype.concat,// which means if a source value is an Array, the source Array's// values will be inserted into the emitted Array.// observableProto {}; //// Selects a value from a sequence. If the source value is an Array,// the source value is applied to the selector as arguments with// func.apply. The optional `count` and `parent` values are appended// to the end of the arguments list.// // Example:// // Rx.Observable.returnValue(["Hey", {name: Paul}])// .multiSelect(function(message, user) {// return message + " " + user.name;// })// .subscribe(function(customized_greeting){// console.log(customized_greeting); // prints "Hey Paul"// });//observableProtomultiSelect =observableProtoselectMulti =observableProto {}; observableProtomulitScan =observableProtoscanMulti =observableProto {}; //// Concatonates source and selected values from a sequence, emitting an// Array of all the values. If the source or selected value is an Array,// the contents are concatonated into a single Array.// For example:// // Rx.Observable.returnValue([1, 2])// .selectConcat(function() { return [3, 4] })// .subscribe(function(values){// console.log(values); // prints [1, 2, 3, 4]// });// observableProtoconcatSelect =observableProto {}; // Selects the field chain from each source value.// A field chain can be a string or a list of arguments.// // For example:// // Rx.Observable// .returnValue({ coords: { global: {x: 10 } } })// .pluck('coords', 'global', 'x')// .subscribe(function(x_value) {// console.log(x_value); // prints 10// });// // The arguments to `pluck` could also be in these formats:// pluck('coords.global.x')// pluck('coords.global', 'x')// pluck('coords', 'global.x')// ...etc.//observableProtopluck =observableProtofield =observableProtovalueOf =observableProtoproperty =observableProtoselectField =observableProtoselectValueAt =observableProto {}; // Invokes the function chain for each source value.// Uses each source value as the invocation context.// // If the value in the chain isn't a function, the value is// selected for instead.// // All arguments after the method_chain are used as arguments// for each function in the chain, in the order they're specified.// // Arrays are applied to their corresponding function as arguments.// // If a function in the chain doesn't accept arguments but others// further down the chain do, pass an empty Array to use as a placeholder.// // If a function is returned by one of the functions in the chain,// passing 'call' in the method_chain will invoke it as part of the chain.// // Example:// // Rx.Observable.returnValue({// bottomRight: function(rect) {// return function() {// return {// x: function(padding) { return rect.x + rect.width + padding; },// y: function(padding) { return rect.y + rect.height + padding; }// };// }// }// })// .invoke("bottomRight.call.y", {x: 10, width: 50, y: 15, height: 85}, [], 10)// .subscribe(function(bottom_with_offset) {// console.log(bottom_with_offset); // prints 110// })// observableProtoinvoke =observableProtocallMethod =observableProtocallFunction =observableProto {}; // // Filters for source values whose fields match the specified value.// The first argument is the field to match, remaining arguments are// treated as a field chain.// // Example:// // Rx.Observable// .returnValue({ coords: { global: { x: 10 } } })// .whereEqualTo(10, 'coords.global', 'x')// .subscribe(function(obj) {// console.log(obj.coords.global.x); // prints 10// });// observableProtowhereEqual =observableProtowhereEquals =observableProto {}; // // Filters for source values whose fields *don't* match the specified value.// The first argument is the field to match against, remaining arguments are// treated as a field chain.// // Example:// // Rx.Observable// .returnValue({ coords: { global: { x: 10 } } })// .whereEqualTo(10, 'coords.global', 'x')// .subscribe(function(obj) {// console.log(obj.coords.global.x); // prints 10// });// observableProtowhereNot =observableProto {}; // // Filters for source values whose values at the field_or_method chain// match the specified value.// // Additional arguments are treated as arguments for the methods in the chain.// See observableProto.invoke for more information on method chains.// observableProtowhereInvoke =observableProto {}; // // Filters for source values whose values at the fields_or_method chain// *don't* match the specified value.// // Additional arguments are treated as arguments for the methods in the chain.// See 'invoke' for more information on method chains.// observableProtowhereInvokeNot =observableProto {}; // // Filters for source values that are greater than (>) the specified value.// Additional arguments are treated as a field chain.// observableProtogt =observableProtogreaterThan =observableProtowhereGT =observableProto {}; // // Filters for source values that are greater than or equal to (>=) the specified value.// Additional arguments are treated as a field chain.// observableProtogte =observableProtowhereGTE =observableProtogreaterThanOrEqualTo =observableProto {}; // // Filters for source values that are less than (<) the specified value.// Additional arguments are treated as a field chain.// observableProtolt =observableProtowhereLT =observableProtolessThan =observableProto {}; // // Filters for source values that are less than or equal to (<=) the specified value.// Additional arguments are treated as a field chain.// observableProtolte =observableProtowhereLTE = observableProtolessThanOrEqualTo =observableProto {}; // // Optionally dispatches the last value from the Observable sequence to the supplied// onCompleted function. Rather than tracking the values in local state or using aggregate,// takeLast, or publishLast, it's easier to do this. YMMV.// // If onCompleted takes no arguments, it's invoked like normal.// If onCompleted takes one argument, the last value is passed as the single argument.// If onCompleted takes multiple arguments and the last value is an Array, the lastValue is// applied to the function as a list of arguments.// Otherwise the onComplete function is passed the last value as a single argument.// observableProto {}; // // Applies source values to the onNext function as an arguments list with func.apply.// observableProtosubscribeMulti =observableProto {}; // // Applies source values to the onNext function as an arguments list with func.apply// and calls the onCompleted function with the last emitted value.// observableProtosubscribeMultiWithLast =observableProto {}