Comparing version 2.0.2 to 2.1.0
{ | ||
"name": "rx", | ||
"title": "Reactive Extensions for JavaScript (RxJS)", | ||
"description": "Library for composing asynchronous and event-based operations in JavaScript", | ||
"version": "2.0.2", | ||
"homepage": "http://rx.codeplex.com/", | ||
"author": { | ||
"name": "Cloud Programmability Team", | ||
"url": "https://github.com/Reactive-Extensions/RxJS/blob/master/authors.txt" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://git01.codeplex.com/rx" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "Apache License, Version 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0" | ||
} | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"grunt": "~0.3.9" | ||
}, | ||
"keywords": ["asynchronous", "async", "reactive", "flow control", "complex event processing"], | ||
"main": "rx.node.js" | ||
} | ||
"name": "rx", | ||
"title": "Reactive Extensions for JavaScript (RxJS)", | ||
"description": "Library for composing asynchronous and event-based operations in JavaScript", | ||
"version": "2.1.0", | ||
"homepage": "http://rx.codeplex.com", | ||
"author": { | ||
"name": "Cloud Programmability Team", | ||
"url": "https://github.com/Reactive-Extensions/RxJS/blob/master/authors.txt" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Reactive-Extensions/RxJS.git" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "Apache License, Version 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
} | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"grunt": "~0.4.0", | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
"grunt-contrib-uglify": "*", | ||
"grunt-contrib-concat": "*", | ||
"grunt-contrib-qunit": "*" | ||
}, | ||
"keywords": [], | ||
"main": "rx.node.js" | ||
} |
@@ -1,7 +0,16 @@ | ||
# RxJS - Reactive Extensions for JavaScript # | ||
# The Reactive Extensions for JavaScript... # | ||
*...is a set of libraries to compose asynchronous and event-based programs using observable collections and LINQ-style query operators in JavaScript* | ||
---------- | ||
This project has moved to [CodePlex](http://rx.codeplex.com/) and only serves as a mirror. | ||
The Reactive Extensions for JavaScript (RxJS) are a set of libraries for composing and coordinating asynchronous and event-based programming that works across many JavaScript runtimes including all browsers and Node.js. | ||
## About the Reactive Extensions ## | ||
The Reactive Extensions for JavaScript (RxJS) is a set of libraries for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in JavaScript. Using RxJS, developers represent asynchronous data streams with Observables, query asynchronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, RxJS = Observables + LINQ + Schedulers. | ||
Whether you are authoring a web-based application in JavaScript or a server-side application in Node.js, you have to deal with asynchronous and event-based programming as a matter of course. Although some patterns are emerging such as the Promise pattern, handling exceptions, cancellation, and synchronization is difficult and error-prone. | ||
Using RxJS, you can represent multiple asynchronous data streams (that come from diverse sources, e.g., stock quote, tweets, computer events, web service requests, etc.), and subscribe to the event stream using the Observer object. The Observable notifies the subscribed Observer instance whenever an event occurs. | ||
Because observable sequences are data streams, you can query them using standard LINQ query operators implemented by the Observable type. Thus you can filter, project, aggregate, compose and perform time-based operations on multiple events easily by using these static LINQ operators. In addition, there are a number of other reactive stream specific operators that allow powerful queries to be written. Cancellation, exceptions, and synchronization are also handled gracefully by using the methods on the Observable object. | ||
This set of libraries include: | ||
@@ -18,6 +27,40 @@ | ||
## Getting Started ## | ||
Coming Soon | ||
## API Documentation ## | ||
Core: | ||
- Observer | ||
- [Observable](https://github.com/Reactive-Extensions/RxJS/wiki/Observable) | ||
Subjects: | ||
- AsyncSubject | ||
- BehaviorSubject | ||
- ReplaySubject | ||
- Subject | ||
Schedulers: | ||
- Scheduler object | ||
- Scheduler.currentThread | ||
- Scheduler.immediate | ||
- Scheduler.timeout | ||
- VirtualTimeScheduler | ||
Disposables: | ||
- CompositeDisposable | ||
- Disposable | ||
- RefCountDisposable | ||
- SerialDisposable | ||
- SingleAssignmentDisposable | ||
## Installation and Usage ## | ||
---------- | ||
There are multiple ways of getting started with the Reactive Extensions including: | ||
@@ -27,13 +70,13 @@ | ||
<script src="rx.js><script> | ||
<script src="rx.js"></script> | ||
Along with a number of our extras for RxJS: | ||
<script src="rx.aggregates.js><script> | ||
<script src="rx.binding.js><script> | ||
<script src="rx.coincidencejs><script> | ||
<script src="rx.experimental.js><script> | ||
<script src="rx.joinpatterns.js><script> | ||
<script src="rx.testing.js><script> | ||
<script src="rx.time.js><script> | ||
<script src="rx.aggregates.js"></script> | ||
<script src="rx.binding.js"></script> | ||
<script src="rx.coincidencejs"></script> | ||
<script src="rx.experimental.js"></script> | ||
<script src="rx.joinpatterns.js"></script> | ||
<script src="rx.testing.js"></script> | ||
<script src="rx.time.js"></script> | ||
@@ -76,5 +119,8 @@ Installing via NPM: | ||
## Compatibility ## | ||
RxJS has been thoroughly tested against all major browsers and supports IE6+, Chrome 4+, FireFox 1+, and Node.js v0.4+. | ||
## License ## | ||
---------- | ||
@@ -81,0 +127,0 @@ Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. |
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -103,2 +86,14 @@ var freeExports = typeof exports == 'object' && exports && | ||
// Aggregation methods | ||
/** | ||
* Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value. | ||
* For aggregation behavior with incremental intermediate results, see Observable.scan. | ||
* | ||
* 1 - res = source.aggregate(function (acc, x) { return acc + x; }); | ||
* 2 - res = source.aggregate(0, function (acc, x) { return acc + x; }); | ||
* @param [seed] The initial accumulator value. | ||
* @param accumulator An accumulator function to be invoked on each element. | ||
* @return An observable sequence containing a single element with the final accumulator value. | ||
*/ | ||
observableProto.aggregate = function () { | ||
@@ -116,3 +111,21 @@ var seed, hasSeed, accumulator; | ||
observableProto.any = function (predicate) { | ||
observableProto.reduce = function () { | ||
var seed, hasSeed, accumulator = arguments[0]; | ||
if (arguments.length === 2) { | ||
hasSeed = true; | ||
seed = arguments[1]; | ||
} | ||
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue(); | ||
}; | ||
/** | ||
* Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence. | ||
* | ||
* 1 - source.any(); | ||
* 2 - source.any(function (x) { return x > 3; }); | ||
* | ||
* @param {Function} [predicate] A function to test each element for a condition. | ||
* @return An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence. | ||
*/ | ||
observableProto.any = observableProto.some = function (predicate) { | ||
var source = this; | ||
@@ -132,2 +145,7 @@ return predicate | ||
/** | ||
* Determines whether an observable sequence is empty. | ||
* | ||
* @return An observable sequence containing a single element determining whether the source sequence is empty. | ||
*/ | ||
observableProto.isEmpty = function () { | ||
@@ -137,3 +155,11 @@ return this.any().select(function (b) { return !b; }); | ||
observableProto.all = function (predicate) { | ||
/** | ||
* Determines whether all elements of an observable sequence satisfy a condition. | ||
* | ||
* 1 - res = source.all(function (value) { return value.length > 3; }); | ||
* | ||
* @param {Function} [predicate] A function to test each element for a condition. | ||
* @return An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate. | ||
*/ | ||
observableProto.all = observableProto.every = function (predicate) { | ||
return this.where(function (v) { | ||
@@ -146,2 +172,12 @@ return !predicate(v); | ||
/** | ||
* Determines whether an observable sequence contains a specified element with an optional equality comparer. | ||
* | ||
* 1 - res = source.contains(42); | ||
* 2 - res = source.contains({ value: 42 }, function (x, y) { return x.value === y.value; }); | ||
* | ||
* @param value The value to locate in the source sequence.</param> | ||
* @param {Function} [comparer] An equality comparer to compare elements. | ||
* @return An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value. | ||
*/ | ||
observableProto.contains = function (value, comparer) { | ||
@@ -154,2 +190,11 @@ comparer || (comparer = defaultComparer); | ||
/** | ||
* Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items. | ||
* | ||
* 1 - res = source.count(); | ||
* 2 - res = source.count(function (x) { return x > 3; }); | ||
* | ||
* @param {Function} [predicate]A function to test each element for a condition. | ||
* @return An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence. | ||
*/ | ||
observableProto.count = function (predicate) { | ||
@@ -163,2 +208,11 @@ return predicate ? | ||
/** | ||
* Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence. | ||
* | ||
* 1 - res = source.sum(); | ||
* 2 - res = source.sum(function (x) { return x.value; }); | ||
* | ||
* @param {Function} [selector]A transform function to apply to each element. | ||
* @return An observable sequence containing a single element with the sum of the values in the source sequence. | ||
*/ | ||
observableProto.sum = function (keySelector) { | ||
@@ -172,2 +226,12 @@ return keySelector ? | ||
/** | ||
* Returns the elements in an observable sequence with the minimum key value according to the specified comparer. | ||
* | ||
* 1 - source.minBy(function (x) { return x.value; }); | ||
* 2 - source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; }); | ||
* | ||
* @param {Function} keySelector Key selector function.</param> | ||
* @param {Function} [comparer] Comparer used to compare key values.</param> | ||
* @return An observable sequence containing a list of zero or more elements that have a minimum key value. | ||
*/ | ||
observableProto.minBy = function (keySelector, comparer) { | ||
@@ -180,2 +244,11 @@ comparer || (comparer = subComparer); | ||
/** | ||
* Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check. | ||
* | ||
* 1 - source.min(); | ||
* 2 - source.min(function (x, y) { return x.value - y.value; }); | ||
* | ||
* @param {Function} [comparer] Comparer used to compare elements. | ||
* @return An observable sequence containing a single element with the minimum element in the source sequence. | ||
*/ | ||
observableProto.min = function (comparer) { | ||
@@ -187,2 +260,12 @@ return this.minBy(identity, comparer).select(function (x) { | ||
/** | ||
* Returns the elements in an observable sequence with the maximum key value according to the specified comparer. | ||
* | ||
* 1 - source.maxBy(function (x) { return x.value; }); | ||
* 2 - source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; }); | ||
* | ||
* @param {Function} keySelector Key selector function. | ||
* @param {Function} [comparer] Comparer used to compare key values. | ||
* @return An observable sequence containing a list of zero or more elements that have a maximum key value. | ||
*/ | ||
observableProto.maxBy = function (keySelector, comparer) { | ||
@@ -193,2 +276,11 @@ comparer || (comparer = subComparer); | ||
/** | ||
* Returns the maximum value in an observable sequence according to the specified comparer. | ||
* | ||
* 1 - source.max(); | ||
* 2 - source.max(function (x, y) { return x.value - y.value; }); | ||
* | ||
* @param {Function} [comparer] Comparer used to compare elements. | ||
* @return An observable sequence containing a single element with the maximum element in the source sequence. | ||
*/ | ||
observableProto.max = function (comparer) { | ||
@@ -200,2 +292,11 @@ return this.maxBy(identity, comparer).select(function (x) { | ||
/** | ||
* Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present. | ||
* | ||
* 1 - res = source.average(); | ||
* 2 - res = source.average(function (x) { return x.value; }); | ||
* | ||
* @param {Function} [selector] A transform function to apply to each element. | ||
* @return An observable sequence containing a single element with the average of the sequence of values. | ||
*/ | ||
observableProto.average = function (keySelector) { | ||
@@ -241,2 +342,14 @@ return keySelector ? | ||
/** | ||
* Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer. | ||
* | ||
* 1 - res = source.sequenceEqual([1,2,3]); | ||
* 2 - res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; }); | ||
* 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42)); | ||
* 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; }); | ||
* | ||
* @param second Second observable sequence or array to compare. | ||
* @param {Function} [comparer] Comparer used to compare elements of both sequences. | ||
* @return An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer. | ||
*/ | ||
observableProto.sequenceEqual = function (second, comparer) { | ||
@@ -341,2 +454,10 @@ var first = this; | ||
/** | ||
* Returns the element at a specified index in a sequence. | ||
* | ||
* source.elementAt(5); | ||
* | ||
* @param {Number} index The zero-based index of the element to retrieve. | ||
* @return An observable sequence that produces the element at the specified position in the source sequence. | ||
*/ | ||
observableProto.elementAt = function (index) { | ||
@@ -346,2 +467,12 @@ return elementAtOrDefault(this, index, false); | ||
/** | ||
* Returns the element at a specified index in a sequence or a default value if the index is out of range. | ||
* | ||
* source.elementAtOrDefault(5); | ||
* source.elementAtOrDefault(5, 0); | ||
* | ||
* @param {Number} index The zero-based index of the element to retrieve. | ||
* @param [defaultValue] The default value if the index is outside the bounds of the source sequence. | ||
* @return An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence. | ||
*/ | ||
observableProto.elementAtOrDefault = function (index, defaultValue) { | ||
@@ -372,2 +503,11 @@ return elementAtOrDefault(this, index, true, defaultValue); | ||
/** | ||
* Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence. | ||
* | ||
* 1 - res = source.single(); | ||
* 2 - res = source.single(function (x) { return x === 42; }); | ||
* | ||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence. | ||
* @return Sequence containing the single element in the observable sequence that satisfies the condition in the predicate. | ||
*/ | ||
observableProto.single = function (predicate) { | ||
@@ -380,2 +520,14 @@ if (predicate) { | ||
/** | ||
* Returns the only element of an observable sequence that matches the predicate, or a default value if no such element exists; this method reports an exception if there is more than one element in the observable sequence. | ||
* | ||
* 1 - res = source.singleOrDefault(); | ||
* 2 - res = source.singleOrDefault(function (x) { return x === 42; }); | ||
* 3 - res = source.singleOrDefault(function (x) { return x === 42; }, 0); | ||
* 4 - res = source.singleOrDefault(null, 0); | ||
* | ||
* @param {Function} predicate A predicate function to evaluate for elements in the source sequence. | ||
* @param [defaultValue] The default value if the index is outside the bounds of the source sequence. | ||
* @return Sequence containing the single element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. | ||
*/ | ||
observableProto.singleOrDefault = function (predicate, defaultValue) { | ||
@@ -404,2 +556,11 @@ if (predicate) { | ||
/** | ||
* Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence. | ||
* | ||
* 1 - res = source.first(); | ||
* 2 - res = source.first(function (x) { return x > 3; }); | ||
* | ||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence. | ||
* @return Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence. | ||
*/ | ||
observableProto.first = function (predicate) { | ||
@@ -412,2 +573,13 @@ if (predicate) { | ||
/** | ||
* Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. | ||
* 1 - res = source.firstOrDefault(); | ||
* 2 - res = source.firstOrDefault(function (x) { return x > 3; }); | ||
* 3 - res = source.firstOrDefault(function (x) { return x > 3; }, 0); | ||
* 4 - res = source.firstOrDefault(null, 0); | ||
* | ||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence. | ||
* @param [defaultValue] The default value if no such element exists. If not specified, defaults to null. | ||
* @return Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. | ||
*/ | ||
observableProto.firstOrDefault = function (predicate, defaultValue) { | ||
@@ -437,2 +609,11 @@ if (predicate) { | ||
/** | ||
* Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element. | ||
* | ||
* 1 - res = source.last(); | ||
* 2 - res = source.last(function (x) { return x > 3; }); | ||
* | ||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence. | ||
* @return Sequence containing the last element in the observable sequence that satisfies the condition in the predicate. | ||
*/ | ||
observableProto.last = function (predicate) { | ||
@@ -445,2 +626,14 @@ if (predicate) { | ||
/** | ||
* Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. | ||
* | ||
* 1 - res = source.lastOrDefault(); | ||
* 2 - res = source.lastOrDefault(function (x) { return x > 3; }); | ||
* 3 - res = source.lastOrDefault(function (x) { return x > 3; }, 0); | ||
* 4 - res = source.lastOrDefault(null, 0); | ||
* | ||
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence. | ||
* @param [defaultValue] The default value if no such element exists. If not specified, defaults to null. | ||
* @return Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. | ||
*/ | ||
observableProto.lastOrDefault = function (predicate, defaultValue) { | ||
@@ -447,0 +640,0 @@ if (predicate) { |
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -59,2 +42,18 @@ var freeExports = typeof exports == 'object' && exports && | ||
/** | ||
* Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each | ||
* subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's | ||
* invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay. | ||
* | ||
* 1 - res = source.multicast(observable); | ||
* 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; }); | ||
* | ||
* @param subjectOrSubjectSelector | ||
* Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function. | ||
* Or: | ||
* Subject to push source elements into. | ||
* | ||
* @param selector [Optional] Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name="subjectOrSubjectSelector" is a factory function. | ||
* @return An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. | ||
*/ | ||
observableProto.multicast = function (subjectOrSubjectSelector, selector) { | ||
@@ -70,2 +69,12 @@ var source = this; | ||
/** | ||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence. | ||
* This operator is a specialization of Multicast using a regular Subject. | ||
* | ||
* 1 - res = source.publish(); | ||
* 2 - res = source.publish(function (x) { return x; }); | ||
* | ||
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on. | ||
* @return An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. | ||
*/ | ||
observableProto.publish = function (selector) { | ||
@@ -79,2 +88,12 @@ return !selector ? | ||
/** | ||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification. | ||
* This operator is a specialization of Multicast using a AsyncSubject. | ||
* | ||
* 1 - res = source.publishLast(); | ||
* 2 - res = source.publishLast(function (x) { return x; }); | ||
* | ||
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source. | ||
* @return An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. | ||
*/ | ||
observableProto.publishLast = function (selector) { | ||
@@ -88,2 +107,13 @@ return !selector ? | ||
/** | ||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue. | ||
* This operator is a specialization of Multicast using a BehaviorSubject. | ||
* | ||
* 1 - res = source.publishValue(42); | ||
* 2 - res = source.publishLast(function (x) { return x.select(function (y) { return y * y; }) }, 42); | ||
* | ||
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on. | ||
* @param initialValue Initial value received by observers upon subscription. | ||
* @return An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. | ||
*/ | ||
observableProto.publishValue = function (initialValueOrSelector, initialValue) { | ||
@@ -97,2 +127,17 @@ return arguments.length === 2 ? | ||
/** | ||
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer. | ||
* This operator is a specialization of Multicast using a ReplaySubject. | ||
* | ||
* 1 - res = source.replay(null, 3); | ||
* 2 - res = source.replay(null, 3, 500); | ||
* 3 - res = source.replay(null, 3, 500, scheduler); | ||
* 4 - res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler); | ||
* | ||
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy. | ||
* @param bufferSize [Optional] Maximum element count of the replay buffer. | ||
* @param window [Optional] Maximum time length of the replay buffer. | ||
* @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on. | ||
* @return An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. | ||
*/ | ||
observableProto.replay = function (selector, bufferSize, window, scheduler) { | ||
@@ -118,2 +163,6 @@ return !selector ? | ||
/** | ||
* Represents a value that changes over time. | ||
* Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications. | ||
*/ | ||
var BehaviorSubject = root.BehaviorSubject = (function () { | ||
@@ -138,2 +187,8 @@ function subscribe(observer) { | ||
inherits(BehaviorSubject, Observable); | ||
/** | ||
* Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value. | ||
* | ||
* @param value Initial value sent to observers when no other value has been received by the subject yet. | ||
*/ | ||
function BehaviorSubject(value) { | ||
@@ -198,2 +253,6 @@ BehaviorSubject.super_.constructor.call(this, subscribe); | ||
// Replay Subject | ||
/** | ||
* Represents an object that is both an observable sequence as well as an observer. | ||
* Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. | ||
*/ | ||
var ReplaySubject = root.ReplaySubject = (function (base) { | ||
@@ -240,2 +299,9 @@ var RemovableDisposable = function (subject, observer) { | ||
/** | ||
* Initializes a new instance of the ReplaySubject class with the specified buffer size, window and scheduler. | ||
* | ||
* @param {Number} [bufferSize] Maximum element count of the replay buffer. | ||
* @param {Number} [window] Maximum time length of the replay buffer. | ||
* @param [scheduler] Scheduler the observers are invoked on. | ||
*/ | ||
function ReplaySubject(bufferSize, window, scheduler) { | ||
@@ -242,0 +308,0 @@ this.bufferSize = bufferSize == null ? Number.MAX_VALUE : bufferSize; |
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -282,2 +265,11 @@ var freeExports = typeof exports == 'object' && exports && | ||
// Joins | ||
/** | ||
* Correlates the elements of two sequences based on overlapping durations. | ||
* | ||
* @param right The right observable sequence to join elements for. | ||
* @param leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. | ||
* @param rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. | ||
* @param resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs. | ||
* @return An observable sequence that contains result elements computed from source elements that have an overlapping duration. | ||
*/ | ||
observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { | ||
@@ -374,2 +366,11 @@ var left = this; | ||
// Group Join | ||
/** | ||
* Correlates the elements of two sequences based on overlapping durations, and groups the results. | ||
* | ||
* @param right The right observable sequence to join elements for. | ||
* @param leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. | ||
* @param rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. | ||
* @param resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element. | ||
* @return An observable sequence that contains result elements computed from source elements that have an overlapping duration. | ||
*/ | ||
observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { | ||
@@ -489,2 +490,9 @@ var left = this; | ||
/** | ||
* Projects each element of an observable sequence into zero or more buffers. | ||
* | ||
* @param bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). | ||
* @param [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. | ||
* @return An observable sequence of windows. | ||
*/ | ||
observableProto.buffer = function (bufferOpeningsOrClosingSelector, bufferClosingSelector) { | ||
@@ -505,2 +513,9 @@ if (arguments.length === 1 && typeof arguments[0] !== 'function') { | ||
/** | ||
* Projects each element of an observable sequence into zero or more windows. | ||
* | ||
* @param windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). | ||
* @param [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. | ||
* @return An observable sequence of windows. | ||
*/ | ||
observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) { | ||
@@ -507,0 +522,0 @@ if (arguments.length === 1 && typeof arguments[0] !== 'function') { |
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -75,2 +58,10 @@ var freeExports = typeof exports == 'object' && exports && | ||
/** | ||
* Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. | ||
* This operator allows for a fluent style of writing queries that use the same sequence multiple times. | ||
* | ||
* @param source Source sequence that will be shared in the selector function. | ||
* @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. | ||
* @return An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. | ||
*/ | ||
observableProto.letBind = function (func) { | ||
@@ -80,2 +71,16 @@ return func(this); | ||
/** | ||
* Determines whether an observable collection contains values. | ||
* | ||
* 1 - res = Rx.Observable.ifThen(condition, obs1); | ||
* 2 - res = Rx.Observable.ifThen(condition, obs1, obs2); | ||
* 3 - res = Rx.Observable.ifThen(condition, obs1, scheduler); | ||
* | ||
* @param condition The condition which determines if the thenSource or elseSource will be run. | ||
* @param thenSource The observable sequence that will be run if the condition function returns true. | ||
* @param elseSource | ||
* [Optional] The observable sequence that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. | ||
* | ||
* @return An observable sequence which is either the thenSource or elseSource. | ||
*/ | ||
Observable.ifThen = function (condition, thenSource, elseSourceOrScheduler) { | ||
@@ -92,2 +97,9 @@ return observableDefer(function () { | ||
/** | ||
* Concatenates the observable sequences obtained by running the specified result selector for each element in source. | ||
* | ||
* @param sources An array of values to turn into an observable sequence. | ||
* @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence. | ||
* @return An observable sequence from the concatenated observable sequences. | ||
*/ | ||
Observable.forIn = function (sources, resultSelector) { | ||
@@ -97,2 +109,9 @@ return enumerableForEach(sources, resultSelector).concat(); | ||
/** | ||
* Repeats source as long as condition holds emulating a while loop. | ||
* | ||
* @param condition The condition which determines if the source will be repeated. | ||
* @param source The observable sequence that will be run if the condition function returns true. | ||
* @return An observable sequence which is repeated as long as the condition holds. | ||
*/ | ||
var observableWhileDo = Observable.whileDo = function (condition, source) { | ||
@@ -102,2 +121,9 @@ return enumerableWhile(condition, source).concat(); | ||
/** | ||
* Repeats source as long as condition holds emulating a do while loop. | ||
* | ||
* @param condition The condition which determines if the source will be repeated. | ||
* @param source The observable sequence that will be run if the condition function returns true. | ||
* @return An observable sequence which is repeated as long as the condition holds. | ||
*/ | ||
observableProto.doWhile = function (condition) { | ||
@@ -107,2 +133,16 @@ return observableConcat([this, observableWhileDo(condition, this)]); | ||
/** | ||
* Uses selector to determine which source in sources to use. | ||
* | ||
* 1 - res = Rx.Observable.switchCase(selector, { '1': obs1, '2': obs2 }); | ||
* 1 - res = Rx.Observable.switchCase(selector, { '1': obs1, '2': obs2 }, obs0); | ||
* 1 - res = Rx.Observable.switchCase(selector, { '1': obs1, '2': obs2 }, scheduler); | ||
* | ||
* @param selector The function which extracts the value for to test in a case statement. | ||
* @param sources A object which has keys which correspond to the case statement labels. | ||
* @param elseSource | ||
* [Optional] The observable sequence that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. | ||
* | ||
* @return An observable sequence which is determined by a case statement. | ||
*/ | ||
Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) { | ||
@@ -120,2 +160,9 @@ return observableDefer(function () { | ||
/** | ||
* Expands an observable sequence by recursively invoking selector. | ||
* | ||
* @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. | ||
* @param scheduler [Optional] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. | ||
* @return An observable sequence containing all the elements produced by the recursive expansion. | ||
*/ | ||
observableProto.expand = function (selector, scheduler) { | ||
@@ -178,2 +225,10 @@ scheduler || (scheduler = immediateScheduler); | ||
/** | ||
* Runs all observable sequences in parallel and collect their last elements. | ||
* | ||
* 1 - res = Rx.Observable.forkJoin([obs1, obs2]); | ||
* 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...); | ||
* | ||
* @return An observable sequence with an array collecting the last elements of all the input sequences. | ||
*/ | ||
Observable.forkJoin = function () { | ||
@@ -229,2 +284,9 @@ var allSources = argsOrArray(arguments, 0); | ||
/** | ||
* Runs two observable sequences in parallel and combines their last elemenets. | ||
* | ||
* @param second Second observable sequence. | ||
* @param resultSelector Result selector function to invoke with the last elements of both sequences. | ||
* @return An observable sequence with the result of calling the selector function with the last elements of both input sequences. | ||
*/ | ||
observableProto.forkJoin = function (second, resultSelector) { | ||
@@ -231,0 +293,0 @@ var first = this; |
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -99,6 +82,16 @@ var freeExports = typeof exports == 'object' && exports && | ||
// Pattern | ||
/** | ||
* @constructor | ||
* Represents a join pattern over observable sequences. | ||
*/ | ||
function Pattern(patterns) { | ||
this.patterns = patterns; | ||
} | ||
/** | ||
* Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value. | ||
* | ||
* @param other Observable sequence to match in addition to the current pattern. | ||
* @return Pattern object that matches when all observable sequences in the pattern have an available value. | ||
*/ | ||
Pattern.prototype.and = function (other) { | ||
@@ -109,2 +102,9 @@ var patterns = this.patterns.slice(0); | ||
}; | ||
/** | ||
* Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values. | ||
* | ||
* @param selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern. | ||
* @return Plan that produces the projected values, to be fed (with other plans) to the when operator. | ||
*/ | ||
Pattern.prototype.then = function (selector) { | ||
@@ -260,8 +260,29 @@ return new Plan(this, selector); | ||
// Observable extensions | ||
/** | ||
* Creates a pattern that matches when both observable sequences have an available value. | ||
* | ||
* @param right Observable sequence to match with the current sequence.</param> | ||
* @return Pattern object that matches when both observable sequences have an available value. | ||
*/ | ||
observableProto.and = function (right) { | ||
return new Pattern([this, right]); | ||
}; | ||
/** | ||
* Matches when the observable sequence has an available value and projects the value. | ||
* | ||
* @param selector Selector that will be invoked for values in the source sequence.</param> | ||
* @return Plan that produces the projected values, to be fed (with other plans) to the when operator. | ||
*/ | ||
observableProto.then = function (selector) { | ||
return new Pattern([this]).then(selector); | ||
}; | ||
/** | ||
* Joins together the results from several patterns. | ||
* | ||
* @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.</param> | ||
* @return Observable sequence with the results form matching several patterns. | ||
*/ | ||
Observable.when = function () { | ||
@@ -268,0 +289,0 @@ var plans = argsOrArray(arguments, 0); |
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -86,5 +69,19 @@ var freeExports = typeof exports == 'object' && exports && | ||
var ReactiveTest = root.ReactiveTest = { | ||
/** Default virtual time used for creation of observable sequences in unit tests. */ | ||
created: 100, | ||
/** Default virtual time used to subscribe to observable sequences in unit tests. */ | ||
subscribed: 200, | ||
/** Default virtual time used to dispose subscriptions in <see cref="ReactiveTest"/>-based unit tests. */ | ||
disposed: 1000, | ||
/** | ||
* Factory method for an OnNext notification record at a given time with a given value or a predicate function. | ||
* | ||
* 1 - ReactiveTest.onNext(200, 42); | ||
* 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; }); | ||
* | ||
* @param ticks Recorded virtual time the OnNext notification occurs. | ||
* @param value Recorded value stored in the OnNext notification or a predicate. | ||
* @return Recorded OnNext notification. | ||
*/ | ||
onNext: function (ticks, value) { | ||
@@ -96,2 +93,12 @@ if (typeof value === 'function') { | ||
}, | ||
/** | ||
* Factory method for an OnError notification record at a given time with a given error. | ||
* | ||
* 1 - ReactiveTest.onNext(200, new Error('error')); | ||
* 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; }); | ||
* | ||
* @param ticks Recorded virtual time the OnError notification occurs. | ||
* @param exception Recorded exception stored in the OnError notification. | ||
* @return Recorded OnError notification. | ||
*/ | ||
onError: function (ticks, exception) { | ||
@@ -103,5 +110,18 @@ if (typeof exception === 'function') { | ||
}, | ||
/** | ||
* Factory method for an OnCompleted notification record at a given time. | ||
* | ||
* @param ticks Recorded virtual time the OnCompleted notification occurs. | ||
* @return Recorded OnCompleted notification. | ||
*/ | ||
onCompleted: function (ticks) { | ||
return new Recorded(ticks, Notification.createOnCompleted()); | ||
}, | ||
/** | ||
* Factory method for a subscription record based on a given subscription and disposal time. | ||
* | ||
* @param start Virtual time indicating when the subscription was created. | ||
* @param end Virtual time indicating when the subscription was disposed. | ||
* @return Subscription object. | ||
*/ | ||
subscribe: function (start, end) { | ||
@@ -112,2 +132,10 @@ return new Subscription(start, end); | ||
/** | ||
* @constructor | ||
* Creates a new object recording the production of the specified value at the given virtual time. | ||
* | ||
* @param time Virtual time the value was produced on. | ||
* @param value Value that was produced. | ||
* @param comparer An optional comparer. | ||
*/ | ||
var Recorded = root.Recorded = function (time, value, comparer) { | ||
@@ -118,5 +146,16 @@ this.time = time; | ||
}; | ||
/** | ||
* Checks whether the given recorded object is equal to the current instance. | ||
* @param other Recorded object to check for equality. | ||
* @return true if both objects are equal; false otherwise. | ||
*/ | ||
Recorded.prototype.equals = function (other) { | ||
return this.time === other.time && this.comparer(this.value, other.value); | ||
}; | ||
/** | ||
* Returns a string representation of the current Recorded value. | ||
* @return String representation of the current Recorded value. | ||
*/ | ||
Recorded.prototype.toString = function () { | ||
@@ -126,2 +165,8 @@ return this.value.toString() + '@' + this.time; | ||
/** | ||
* @constructor | ||
* Creates a new subscription object with the given virtual subscription and unsubscription time. | ||
* @param subscribe Virtual time at which the subscription occurred. | ||
* @param unsubscribe Virtual time at which the unsubscription occurred. | ||
*/ | ||
var Subscription = root.Subscription = function (start, end) { | ||
@@ -131,5 +176,16 @@ this.subscribe = start; | ||
}; | ||
/** | ||
* Checks whether the given subscription is equal to the current instance. | ||
* @param other Subscription object to check for equality. | ||
* @return true if both objects are equal; false otherwise. | ||
*/ | ||
Subscription.prototype.equals = function (other) { | ||
return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe; | ||
}; | ||
/** | ||
* Returns a string representation of the current Subscription value. | ||
* @return String representation of the current Subscription value. | ||
*/ | ||
Subscription.prototype.toString = function () { | ||
@@ -237,4 +293,7 @@ return '(' + this.subscribe + ', ' + this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe + ')'; | ||
/** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */ | ||
root.TestScheduler = (function () { | ||
inherits(TestScheduler, VirtualTimeScheduler); | ||
/** @constructor */ | ||
function TestScheduler() { | ||
@@ -244,2 +303,10 @@ TestScheduler.super_.constructor.call(this, 0, function (a, b) { return a - b; }); | ||
/** | ||
* Schedules an action to be executed at the specified virtual time. | ||
* | ||
* @param state State passed to the action to be executed. | ||
* @param dueTime Absolute virtual time at which to execute the action. | ||
* @param action Action to be executed. | ||
* @return Disposable object used to cancel the scheduled action (best effort). | ||
*/ | ||
TestScheduler.prototype.scheduleAbsoluteWithState = function (state, dueTime, action) { | ||
@@ -251,11 +318,39 @@ if (dueTime <= this.clock) { | ||
}; | ||
/** | ||
* Adds a relative virtual time to an absolute virtual time value. | ||
* | ||
* @param absolute Absolute virtual time value. | ||
* @param relative Relative virtual time value to add. | ||
* @return Resulting absolute virtual time sum value. | ||
*/ | ||
TestScheduler.prototype.add = function (absolute, relative) { | ||
return absolute + relative; | ||
}; | ||
/** | ||
* Converts the absolute virtual time value to a DateTimeOffset value. | ||
* | ||
* @param absolute Absolute virtual time value to convert. | ||
* @return Corresponding DateTimeOffset value. | ||
*/ | ||
TestScheduler.prototype.toDateTimeOffset = function (absolute) { | ||
return new Date(absolute).getTime(); | ||
}; | ||
/** | ||
* Converts the TimeSpan value to a relative virtual time value. | ||
* | ||
* @param timeSpan TimeSpan value to convert. | ||
* @return Corresponding relative virtual time value. | ||
*/ | ||
TestScheduler.prototype.toRelative = function (timeSpan) { | ||
return timeSpan; | ||
}; | ||
/** | ||
* Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription. | ||
* | ||
* @param create Factory method to create an observable sequence. | ||
* @param created Virtual time at which to invoke the factory to create an observable sequence. | ||
* @param subscribed Virtual time at which to subscribe to the created observable sequence. | ||
* @param disposed Virtual time at which to dispose the subscription. | ||
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. | ||
*/ | ||
TestScheduler.prototype.startWithTiming = function (create, created, subscribed, disposed) { | ||
@@ -278,8 +373,28 @@ var observer = this.createObserver(), source, subscription; | ||
}; | ||
/** | ||
* Starts the test scheduler and uses the specified virtual time to dispose the subscription to the sequence obtained through the factory function. | ||
* Default virtual times are used for factory invocation and sequence subscription. | ||
* | ||
* @param create Factory method to create an observable sequence. | ||
* @param disposed Virtual time at which to dispose the subscription. | ||
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. | ||
*/ | ||
TestScheduler.prototype.startWithDispose = function (create, disposed) { | ||
return this.startWithTiming(create, ReactiveTest.created, ReactiveTest.subscribed, disposed); | ||
}; | ||
/** | ||
* Starts the test scheduler and uses default virtual times to invoke the factory function, to subscribe to the resulting sequence, and to dispose the subscription</see>. | ||
* | ||
* @param create Factory method to create an observable sequence. | ||
* @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. | ||
*/ | ||
TestScheduler.prototype.startWithCreate = function (create) { | ||
return this.startWithTiming(create, ReactiveTest.created, ReactiveTest.subscribed, ReactiveTest.disposed); | ||
}; | ||
/** | ||
* Creates a hot observable using the specified timestamped notification messages either as an array or arguments. | ||
* | ||
* @param messages Notifications to surface through the created sequence at their specified absolute virtual times. | ||
* @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications. | ||
*/ | ||
TestScheduler.prototype.createHotObservable = function () { | ||
@@ -289,2 +404,8 @@ var messages = argsOrArray(arguments, 0); | ||
}; | ||
/** | ||
* Creates a cold observable using the specified timestamped notification messages either as an array or arguments. | ||
* | ||
* @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time. | ||
* @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications. | ||
*/ | ||
TestScheduler.prototype.createColdObservable = function () { | ||
@@ -294,2 +415,7 @@ var messages = argsOrArray(arguments, 0); | ||
}; | ||
/** | ||
* Creates an observer that records received notification messages and timestamps those. | ||
* | ||
* @return Observer that can be used to assert the timing of received notifications. | ||
*/ | ||
TestScheduler.prototype.createObserver = function () { | ||
@@ -296,0 +422,0 @@ return new MockObserver(this); |
333
rx.time.js
@@ -1,20 +0,3 @@ | ||
/* | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
Microsoft Open Technologies would like to thank its contributors, a list | ||
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
*/ | ||
(function (root, factory) { | ||
@@ -107,2 +90,12 @@ var freeExports = typeof exports == 'object' && exports && | ||
/** | ||
* Returns an observable sequence that produces a value after each period. | ||
* | ||
* 1 - res = Rx.Observable.interval(1000); | ||
* 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout); | ||
* | ||
* @param period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds). | ||
* @param [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used. | ||
* @return An observable sequence that produces a value after each period. | ||
*/ | ||
var observableinterval = Observable.interval = function (period, scheduler) { | ||
@@ -113,2 +106,20 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. | ||
* | ||
* 1 - res = Rx.Observable.timer(new Date()); | ||
* 2 - res = Rx.Observable.timer(new Date(), 1000); | ||
* 3 - res = Rx.Observable.timer(new Date(), Rx.Scheduler.timeout); | ||
* 4 - res = Rx.Observable.timer(new Date(), 1000, Rx.Scheduler.timeout); | ||
* | ||
* 5 - res = Rx.Observable.timer(5000); | ||
* 6 - res = Rx.Observable.timer(5000, 1000); | ||
* 7 - res = Rx.Observable.timer(5000, Rx.Scheduler.timeout); | ||
* 8 - res = Rx.Observable.timer(5000, 1000, Rx.Scheduler.timeout); | ||
* | ||
* @param dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. | ||
* @param [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring. | ||
* @param [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence that produces a value after due time has elapsed and then each period. | ||
*/ | ||
var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { | ||
@@ -208,2 +219,15 @@ var period; | ||
/** | ||
* Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved. | ||
* | ||
* 1 - res = Rx.Observable.timer(new Date()); | ||
* 2 - res = Rx.Observable.timer(new Date(), Rx.Scheduler.timeout); | ||
* | ||
* 3 - res = Rx.Observable.delay(5000); | ||
* 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout); | ||
* | ||
* @param dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence. | ||
* @param [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used. | ||
* @return Time-shifted sequence. | ||
*/ | ||
observableProto.delay = function (dueTime, scheduler) { | ||
@@ -216,2 +240,12 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Ignores values from an observable sequence which are followed by another value before dueTime. | ||
* | ||
* 1 - res = source.throttle(5000); // 5 seconds | ||
* 2 - res = source.throttle(5000, scheduler); | ||
* | ||
* @param dueTime Duration of the throttle period for each value (specified as an integer denoting milliseconds). | ||
* @param [scheduler] Scheduler to run the throttle timers on. If not specified, the timeout scheduler is used. | ||
* @return The throttled sequence. | ||
*/ | ||
observableProto.throttle = function (dueTime, scheduler) { | ||
@@ -254,2 +288,13 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Projects each element of an observable sequence into zero or more windows which are produced based on timing information. | ||
* | ||
* 1 - res = xs.windowWithTime(1000, scheduler); // non-overlapping segments of 1 second | ||
* 2 - res = xs.windowWithTime(1000, 500 , scheduler); // segments of 1 second with time shift 0.5 seconds | ||
* | ||
* @param timeSpan Length of each window (specified as an integer denoting milliseconds). | ||
* @param [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows. | ||
* @param [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence of windows. | ||
*/ | ||
observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { | ||
@@ -345,2 +390,13 @@ var source = this, timeShift; | ||
/** | ||
* Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed. | ||
* | ||
* 1 - res = source.windowWithTimeOrCount(5000, 50); // 5s or 50 items | ||
* 2 - res = source.windowWithTimeOrCount(5000, 50, scheduler); //5s or 50 items | ||
* | ||
* @param timeSpan Maximum time length of a window. | ||
* @param count Maximum element count of a window. | ||
* @param [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence of windows. | ||
*/ | ||
observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) { | ||
@@ -404,2 +460,13 @@ var source = this; | ||
/** | ||
* Projects each element of an observable sequence into zero or more buffers which are produced based on timing information. | ||
* | ||
* 1 - res = xs.bufferWithTime(1000, scheduler); // non-overlapping segments of 1 second | ||
* 2 - res = xs.bufferWithTime(1000, 500, scheduler; // segments of 1 second with time shift 0.5 seconds | ||
* | ||
* @param timeSpan Length of each buffer (specified as an integer denoting milliseconds). | ||
* @param [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers. | ||
* @param [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence of buffers. | ||
*/ | ||
observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { | ||
@@ -422,2 +489,13 @@ var timeShift; | ||
/** | ||
* Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed. | ||
* | ||
* 1 - res = source.bufferWithTimeOrCount(5000, 50); // 5s or 50 items in an array | ||
* 2 - res = source.bufferWithTimeOrCount(5000, 50, scheduler); // 5s or 50 items in an array | ||
* | ||
* @param timeSpan Maximum time length of a buffer. | ||
* @param count Maximum element count of a buffer. | ||
* @param [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence of buffers. | ||
*/ | ||
observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) { | ||
@@ -430,2 +508,11 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Records the time interval between consecutive values in an observable sequence. | ||
* | ||
* 1 - res = source.timeInterval(); | ||
* 2 - res = source.timeInterval(Rx.Scheduler.timeout); | ||
* | ||
* @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence with time interval information on values. | ||
*/ | ||
observableProto.timeInterval = function (scheduler) { | ||
@@ -447,2 +534,11 @@ var source = this; | ||
/** | ||
* Records the timestamp for each value in an observable sequence. | ||
* | ||
* 1 - res = source.timestamp(); // produces { value: x, timestamp: ts } | ||
* 2 - res = source.timestamp(Rx.Scheduler.timeout); | ||
* | ||
* @param [scheduler] Scheduler used to compute timestamps. If not specified, the timeout scheduler is used. | ||
* @return An observable sequence with timestamp information on values. | ||
*/ | ||
observableProto.timestamp = function (scheduler) { | ||
@@ -485,2 +581,14 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Samples the observable sequence at each interval. | ||
* | ||
* 1 - res = source.sample(sampleObservable); // Sampler tick sequence | ||
* 2 - res = source.sample(5000); // 5 seconds | ||
* 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds | ||
* | ||
* @param source Source sequence to sample. | ||
* @param interval Interval at which to sample (specified as an integer denoting milliseconds). | ||
* @param [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used. | ||
* @return Sampled observable sequence. | ||
*/ | ||
observableProto.sample = function (intervalOrSampler, scheduler) { | ||
@@ -494,2 +602,17 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Returns the source observable sequence or the other observable sequence if dueTime elapses. | ||
* | ||
* 1 - res = source.timeout(new Date()); // As a date | ||
* 2 - res = source.timeout(5000); // 5 seconds | ||
* 3 - res = source.timeout(new Date(), Rx.Observable.returnValue(42)); // As a date and timeout observable | ||
* 4 - res = source.timeout(5000, Rx.Observable.returnValue(42)); // 5 seconds and timeout observable | ||
* 5 - res = source.timeout(new Date(), Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // As a date and timeout observable | ||
* 6 - res = source.timeout(5000, Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // 5 seconds and timeout observable | ||
* | ||
* @param dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs. | ||
* @param [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used. | ||
* @param [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used. | ||
* @return The source sequence switching to the other sequence in case of a timeout. | ||
*/ | ||
observableProto.timeout = function (dueTime, other, scheduler) { | ||
@@ -519,5 +642,4 @@ var schedulerMethod, source = this; | ||
timer.disposable(schedulerMethod(dueTime, function () { | ||
var timerWins; | ||
switched = id === myId; | ||
timerWins = switched; | ||
var timerWins = switched; | ||
if (timerWins) { | ||
@@ -553,2 +675,20 @@ subscription.disposable(other.subscribe(observer)); | ||
/** | ||
* Generates an observable sequence by iterating a state from an initial state until the condition fails. | ||
* | ||
* res = source.generateWithAbsoluteTime(0, | ||
* function (x) { return return true; }, | ||
* function (x) { return x + 1; }, | ||
* function (x) { return x; }, | ||
* function (x) { return new Date(); | ||
* }); | ||
* | ||
* @param initialState Initial state. | ||
* @param condition Condition to terminate generation (upon returning false). | ||
* @param iterate Iteration step function. | ||
* @param resultSelector Selector function for results produced in the sequence. | ||
* @param timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values. | ||
* @param [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. | ||
* @return The generated sequence. | ||
*/ | ||
Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { | ||
@@ -590,2 +730,20 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Generates an observable sequence by iterating a state from an initial state until the condition fails. | ||
* | ||
* res = source.generateWithRelativeTime(0, | ||
* function (x) { return return true; }, | ||
* function (x) { return x + 1; }, | ||
* function (x) { return x; }, | ||
* function (x) { return 500; } | ||
* ); | ||
* | ||
* @param initialState Initial state. | ||
* @param condition Condition to terminate generation (upon returning false). | ||
* @param iterate Iteration step function. | ||
* @param resultSelector Selector function for results produced in the sequence. | ||
* @param timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds. | ||
* @param [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. | ||
* @return The generated sequence. | ||
*/ | ||
Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { | ||
@@ -627,2 +785,12 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Time shifts the observable sequence by delaying the subscription. | ||
* | ||
* 1 - res = source.delaySubscription(5000); // 5s | ||
* 2 - res = source.delaySubscription(5000, Rx.Scheduler.timeout); // 5 seconds | ||
* | ||
* @param dueTime Absolute or relative time to perform the subscription at. | ||
* @param [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used. | ||
* @return Time-shifted sequence. | ||
*/ | ||
observableProto.delaySubscription = function (dueTime, scheduler) { | ||
@@ -633,2 +801,12 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Time shifts the observable sequence based on a subscription delay and a delay selector function for each element. | ||
* | ||
* 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only | ||
* 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector | ||
* | ||
* @param [subscriptionDelay] Sequence indicating the delay for the subscription to the source. | ||
* @param delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element. | ||
* @return Time-shifted sequence. | ||
*/ | ||
observableProto.delayWithSelector = function (subscriptionDelay, delayDurationSelector) { | ||
@@ -686,2 +864,14 @@ var source = this, subDelay, selector; | ||
/** | ||
* Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled. | ||
* | ||
* 1 - res = source.timeoutWithSelector(Rx.Observable.timer(500)); | ||
* 2 - res = source.timeoutWithSelector(Rx.Observable.timer(500), function (x) { return Rx.Observable.timer(200); }); | ||
* 3 - res = source.timeoutWithSelector(Rx.Observable.timer(500), function (x) { return Rx.Observable.timer(200); }, Rx.Observable.returnValue(42)); | ||
* | ||
* @param [firstTimeout] Observable sequence that represents the timeout for the first element. If not provided, this defaults to Observable.never(). | ||
* @param [timeoutDurationSelector] Selector to retrieve an observable sequence that represents the timeout between the current element and the next element. | ||
* @param [other] Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException(). | ||
* @return The source sequence switching to the other sequence in case of a timeout. | ||
*/ | ||
observableProto.timeoutWithSelector = function (firstTimeout, timeoutdurationSelector, other) { | ||
@@ -752,2 +942,10 @@ firstTimeout || (firstTimeout = observableNever()); | ||
/** | ||
* Ignores values from an observable sequence which are followed by another value within a computed throttle duration. | ||
* | ||
* 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(x + x); }); | ||
* | ||
* @param throttleDurationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element. | ||
* @return The throttled sequence. | ||
*/ | ||
observableProto.throttleWithSelector = function (throttleDurationSelector) { | ||
@@ -800,3 +998,17 @@ var source = this; | ||
/** | ||
* Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. | ||
* | ||
* 1 - res = source.skipLastWithTime(5000); | ||
* 2 - res = source.skipLastWithTime(5000, scheduler); | ||
* | ||
* @param duration Duration for skipping elements from the end of the sequence. | ||
* @param [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout | ||
* @return An observable sequence with the elements skipped during the specified duration from the end of the source sequence. | ||
* | ||
* This operator accumulates a queue with a length enough to store elements received during the initial duration window. | ||
* As more elements are received, elements older than the specified duration are taken from the queue and produced on the | ||
* result sequence. This causes elements to be delayed with duration. | ||
* | ||
*/ | ||
observableProto.skipLastWithTime = function (duration, scheduler) { | ||
@@ -823,2 +1035,17 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements. | ||
* | ||
* 1 - res = source.takeLastWithTime(5000, [optional timer scheduler], [optional loop scheduler]); | ||
* | ||
* @param duration Duration for taking elements from the end of the sequence. | ||
* @param [timerScheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. | ||
* @param [loopScheduler] Scheduler to drain the collected elements. If not specified, defaults to Rx.Scheduler.immediate. | ||
* @return An observable sequence with the elements taken during the specified duration from the end of the source sequence. | ||
* | ||
* This operator accumulates a buffer with a length enough to store elements for any duration window during the lifetime of | ||
* the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements | ||
* to be delayed with duration. | ||
* | ||
*/ | ||
observableProto.takeLastWithTime = function (duration, timerScheduler, loopScheduler) { | ||
@@ -828,2 +1055,15 @@ return this.takeLastBufferWithTime(duration, timerScheduler).selectMany(function (xs) { return observableFromArray(xs, loopScheduler); }); | ||
/** | ||
* Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. | ||
* | ||
* 1 - res = source.takeLastBufferWithTime(5000, [optional scheduler]); | ||
* | ||
* @param duration Duration for taking elements from the end of the sequence. | ||
* @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. | ||
* @return An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence. | ||
* | ||
* This operator accumulates a buffer with a length enough to store elements for any duration window during the lifetime of | ||
* the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence. | ||
* | ||
*/ | ||
observableProto.takeLastBufferWithTime = function (duration, scheduler) { | ||
@@ -856,2 +1096,16 @@ var source = this; | ||
/** | ||
* Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. | ||
* | ||
* 1 - res = source.takeWithTime(5000, [optional scheduler]); | ||
* | ||
* @param duration Duration for taking elements from the start of the sequence. | ||
* @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. | ||
* @return An observable sequence with the elements taken during the specified duration from the start of the source sequence. | ||
* | ||
* Specifying a zero value for duration doesn't guarantee an empty sequence will be returned. This is a side-effect | ||
* of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute | ||
* immediately, despite the zero due time. | ||
* | ||
*/ | ||
observableProto.takeWithTime = function (duration, scheduler) { | ||
@@ -869,2 +1123,18 @@ var source = this; | ||
/** | ||
* Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. | ||
* | ||
* 1 - res = source.skipWithTime(5000, [optional scheduler]); | ||
* | ||
* @param duration Duration for skipping elements from the start of the sequence. | ||
* @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. | ||
* @return An observable sequence with the elements skipped during the specified duration from the start of the source sequence. | ||
* | ||
* Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence. | ||
* This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded | ||
* may not execute immediately, despite the zero due time. | ||
* | ||
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration. | ||
* | ||
*/ | ||
observableProto.skipWithTime = function (duration, scheduler) { | ||
@@ -886,2 +1156,14 @@ var source = this; | ||
/** | ||
* Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers. | ||
* | ||
* 1 - res = source.skipUntilWithTime(new Date(), [optional scheduler]); | ||
* | ||
* @param startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped. | ||
* @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. | ||
* @return An observable sequence with the elements skipped until the specified start time. | ||
* | ||
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime"/>. | ||
* | ||
*/ | ||
observableProto.skipUntilWithTime = function (startTime, scheduler) { | ||
@@ -903,2 +1185,11 @@ scheduler || (scheduler = timeoutScheduler); | ||
/** | ||
* Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers. | ||
* | ||
* 1 - res = source.takeUntilWithTime(new Date(), [optional scheduler]); | ||
* | ||
* @param endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately. | ||
* @param scheduler Scheduler to run the timer on. | ||
* @return An observable sequence with the elements taken until the specified end time. | ||
*/ | ||
observableProto.takeUntilWithTime = function (endTime, scheduler) { | ||
@@ -905,0 +1196,0 @@ scheduler || (scheduler = timeoutScheduler); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1850521
152
38163
138
6
2
80
8
1