@mastra/nestjs 0.1.8-alpha.0 → 0.1.8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/_types/rxjs/dist/types/index.d.ts +173 -0
- package/dist/_types/rxjs/dist/types/internal/AnyCatcher.d.ts +10 -0
- package/dist/_types/rxjs/dist/types/internal/AsyncSubject.d.ts +15 -0
- package/dist/_types/rxjs/dist/types/internal/BehaviorSubject.d.ts +15 -0
- package/dist/_types/rxjs/dist/types/internal/Notification.d.ts +180 -0
- package/dist/_types/rxjs/dist/types/internal/Observable.d.ts +128 -0
- package/dist/_types/rxjs/dist/types/internal/Operator.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/ReplaySubject.d.ts +49 -0
- package/dist/_types/rxjs/dist/types/internal/Scheduler.d.ts +55 -0
- package/dist/_types/rxjs/dist/types/internal/Subject.d.ts +58 -0
- package/dist/_types/rxjs/dist/types/internal/Subscriber.d.ts +78 -0
- package/dist/_types/rxjs/dist/types/internal/Subscription.d.ts +96 -0
- package/dist/_types/rxjs/dist/types/internal/config.d.ts +73 -0
- package/dist/_types/rxjs/dist/types/internal/firstValueFrom.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/lastValueFrom.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/observable/ConnectableObservable.d.ts +42 -0
- package/dist/_types/rxjs/dist/types/internal/observable/bindCallback.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/observable/bindNodeCallback.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/observable/combineLatest.d.ts +33 -0
- package/dist/_types/rxjs/dist/types/internal/observable/concat.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/observable/connectable.d.ts +27 -0
- package/dist/_types/rxjs/dist/types/internal/observable/defer.d.ts +52 -0
- package/dist/_types/rxjs/dist/types/internal/observable/dom/animationFrames.d.ts +76 -0
- package/dist/_types/rxjs/dist/types/internal/observable/empty.d.ts +72 -0
- package/dist/_types/rxjs/dist/types/internal/observable/forkJoin.d.ts +24 -0
- package/dist/_types/rxjs/dist/types/internal/observable/from.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/observable/fromEvent.d.ts +45 -0
- package/dist/_types/rxjs/dist/types/internal/observable/fromEventPattern.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/observable/generate.d.ts +311 -0
- package/dist/_types/rxjs/dist/types/internal/observable/iif.d.ts +82 -0
- package/dist/_types/rxjs/dist/types/internal/observable/interval.d.ts +49 -0
- package/dist/_types/rxjs/dist/types/internal/observable/merge.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/observable/never.d.ts +40 -0
- package/dist/_types/rxjs/dist/types/internal/observable/of.d.ts +14 -0
- package/dist/_types/rxjs/dist/types/internal/observable/onErrorResumeNext.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/observable/pairs.d.ts +19 -0
- package/dist/_types/rxjs/dist/types/internal/observable/partition.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/observable/race.d.ts +12 -0
- package/dist/_types/rxjs/dist/types/internal/observable/range.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/observable/throwError.d.ts +115 -0
- package/dist/_types/rxjs/dist/types/internal/observable/timer.d.ts +126 -0
- package/dist/_types/rxjs/dist/types/internal/observable/using.d.ts +32 -0
- package/dist/_types/rxjs/dist/types/internal/observable/zip.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/audit.d.ts +48 -0
- package/dist/_types/rxjs/dist/types/internal/operators/auditTime.d.ts +50 -0
- package/dist/_types/rxjs/dist/types/internal/operators/buffer.d.ts +41 -0
- package/dist/_types/rxjs/dist/types/internal/operators/bufferCount.d.ts +54 -0
- package/dist/_types/rxjs/dist/types/internal/operators/bufferTime.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/operators/bufferToggle.d.ts +46 -0
- package/dist/_types/rxjs/dist/types/internal/operators/bufferWhen.d.ts +41 -0
- package/dist/_types/rxjs/dist/types/internal/operators/catchError.d.ts +4 -0
- package/dist/_types/rxjs/dist/types/internal/operators/combineAll.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/operators/combineLatestAll.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/operators/combineLatestWith.d.ts +43 -0
- package/dist/_types/rxjs/dist/types/internal/operators/concatAll.d.ts +59 -0
- package/dist/_types/rxjs/dist/types/internal/operators/concatMap.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/concatMapTo.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/operators/concatWith.d.ts +43 -0
- package/dist/_types/rxjs/dist/types/internal/operators/connect.d.ts +87 -0
- package/dist/_types/rxjs/dist/types/internal/operators/count.d.ts +58 -0
- package/dist/_types/rxjs/dist/types/internal/operators/debounce.d.ts +61 -0
- package/dist/_types/rxjs/dist/types/internal/operators/debounceTime.d.ts +60 -0
- package/dist/_types/rxjs/dist/types/internal/operators/defaultIfEmpty.d.ts +38 -0
- package/dist/_types/rxjs/dist/types/internal/operators/delay.d.ts +59 -0
- package/dist/_types/rxjs/dist/types/internal/operators/delayWhen.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/operators/dematerialize.d.ts +51 -0
- package/dist/_types/rxjs/dist/types/internal/operators/distinct.d.ts +60 -0
- package/dist/_types/rxjs/dist/types/internal/operators/distinctUntilChanged.d.ts +4 -0
- package/dist/_types/rxjs/dist/types/internal/operators/distinctUntilKeyChanged.d.ts +4 -0
- package/dist/_types/rxjs/dist/types/internal/operators/elementAt.d.ts +51 -0
- package/dist/_types/rxjs/dist/types/internal/operators/endWith.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/every.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/operators/exhaust.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/operators/exhaustAll.d.ts +47 -0
- package/dist/_types/rxjs/dist/types/internal/operators/exhaustMap.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/expand.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/operators/filter.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/operators/finalize.d.ts +64 -0
- package/dist/_types/rxjs/dist/types/internal/operators/find.d.ts +12 -0
- package/dist/_types/rxjs/dist/types/internal/operators/findIndex.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/operators/first.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/operators/flatMap.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/operators/groupBy.d.ts +119 -0
- package/dist/_types/rxjs/dist/types/internal/operators/ignoreElements.d.ts +38 -0
- package/dist/_types/rxjs/dist/types/internal/operators/isEmpty.d.ts +64 -0
- package/dist/_types/rxjs/dist/types/internal/operators/last.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/operators/map.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/operators/mapTo.d.ts +10 -0
- package/dist/_types/rxjs/dist/types/internal/operators/materialize.d.ts +52 -0
- package/dist/_types/rxjs/dist/types/internal/operators/max.d.ts +49 -0
- package/dist/_types/rxjs/dist/types/internal/operators/mergeAll.d.ts +62 -0
- package/dist/_types/rxjs/dist/types/internal/operators/mergeMap.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/mergeMapTo.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/operators/mergeScan.d.ts +69 -0
- package/dist/_types/rxjs/dist/types/internal/operators/mergeWith.d.ts +44 -0
- package/dist/_types/rxjs/dist/types/internal/operators/min.d.ts +49 -0
- package/dist/_types/rxjs/dist/types/internal/operators/multicast.d.ts +63 -0
- package/dist/_types/rxjs/dist/types/internal/operators/observeOn.d.ts +56 -0
- package/dist/_types/rxjs/dist/types/internal/operators/onErrorResumeNextWith.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/operators/pairwise.d.ts +46 -0
- package/dist/_types/rxjs/dist/types/internal/operators/pluck.d.ts +18 -0
- package/dist/_types/rxjs/dist/types/internal/operators/publish.d.ts +30 -0
- package/dist/_types/rxjs/dist/types/internal/operators/publishBehavior.d.ts +19 -0
- package/dist/_types/rxjs/dist/types/internal/operators/publishLast.d.ts +69 -0
- package/dist/_types/rxjs/dist/types/internal/operators/publishReplay.d.ts +56 -0
- package/dist/_types/rxjs/dist/types/internal/operators/raceWith.d.ts +29 -0
- package/dist/_types/rxjs/dist/types/internal/operators/reduce.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/operators/refCount.d.ts +61 -0
- package/dist/_types/rxjs/dist/types/internal/operators/repeat.d.ts +108 -0
- package/dist/_types/rxjs/dist/types/internal/operators/repeatWhen.d.ts +38 -0
- package/dist/_types/rxjs/dist/types/internal/operators/retry.d.ts +28 -0
- package/dist/_types/rxjs/dist/types/internal/operators/retryWhen.d.ts +61 -0
- package/dist/_types/rxjs/dist/types/internal/operators/sample.d.ts +43 -0
- package/dist/_types/rxjs/dist/types/internal/operators/sampleTime.d.ts +46 -0
- package/dist/_types/rxjs/dist/types/internal/operators/scan.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/operators/sequenceEqual.d.ts +60 -0
- package/dist/_types/rxjs/dist/types/internal/operators/share.d.ts +43 -0
- package/dist/_types/rxjs/dist/types/internal/operators/shareReplay.d.ts +10 -0
- package/dist/_types/rxjs/dist/types/internal/operators/single.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/operators/skip.d.ts +36 -0
- package/dist/_types/rxjs/dist/types/internal/operators/skipLast.d.ts +45 -0
- package/dist/_types/rxjs/dist/types/internal/operators/skipUntil.d.ts +48 -0
- package/dist/_types/rxjs/dist/types/internal/operators/skipWhile.d.ts +5 -0
- package/dist/_types/rxjs/dist/types/internal/operators/startWith.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/subscribeOn.d.ts +62 -0
- package/dist/_types/rxjs/dist/types/internal/operators/switchAll.d.ts +61 -0
- package/dist/_types/rxjs/dist/types/internal/operators/switchMap.d.ts +7 -0
- package/dist/_types/rxjs/dist/types/internal/operators/switchMapTo.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/operators/switchScan.d.ts +20 -0
- package/dist/_types/rxjs/dist/types/internal/operators/take.d.ts +45 -0
- package/dist/_types/rxjs/dist/types/internal/operators/takeLast.d.ts +42 -0
- package/dist/_types/rxjs/dist/types/internal/operators/takeUntil.d.ts +42 -0
- package/dist/_types/rxjs/dist/types/internal/operators/takeWhile.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/operators/tap.d.ts +72 -0
- package/dist/_types/rxjs/dist/types/internal/operators/throttle.d.ts +78 -0
- package/dist/_types/rxjs/dist/types/internal/operators/throttleTime.d.ts +53 -0
- package/dist/_types/rxjs/dist/types/internal/operators/throwIfEmpty.d.ts +39 -0
- package/dist/_types/rxjs/dist/types/internal/operators/timeInterval.d.ts +50 -0
- package/dist/_types/rxjs/dist/types/internal/operators/timeout.d.ts +257 -0
- package/dist/_types/rxjs/dist/types/internal/operators/timeoutWith.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/operators/timestamp.d.ts +35 -0
- package/dist/_types/rxjs/dist/types/internal/operators/toArray.d.ts +33 -0
- package/dist/_types/rxjs/dist/types/internal/operators/window.d.ts +48 -0
- package/dist/_types/rxjs/dist/types/internal/operators/windowCount.d.ts +66 -0
- package/dist/_types/rxjs/dist/types/internal/operators/windowTime.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/operators/windowToggle.d.ts +51 -0
- package/dist/_types/rxjs/dist/types/internal/operators/windowWhen.d.ts +48 -0
- package/dist/_types/rxjs/dist/types/internal/operators/withLatestFrom.d.ts +4 -0
- package/dist/_types/rxjs/dist/types/internal/operators/zipAll.d.ts +14 -0
- package/dist/_types/rxjs/dist/types/internal/operators/zipWith.d.ts +26 -0
- package/dist/_types/rxjs/dist/types/internal/scheduled/scheduled.d.ts +15 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/Action.d.ts +32 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/AnimationFrameScheduler.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/AsapScheduler.d.ts +6 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/AsyncAction.d.ts +25 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/AsyncScheduler.d.ts +9 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/QueueScheduler.d.ts +4 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/VirtualTimeScheduler.d.ts +49 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/animationFrame.d.ts +38 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/asap.d.ts +41 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/async.d.ts +53 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/queue.d.ts +69 -0
- package/dist/_types/rxjs/dist/types/internal/scheduler/timerHandle.d.ts +2 -0
- package/dist/_types/rxjs/dist/types/internal/symbol/observable.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/types.d.ts +301 -0
- package/dist/_types/rxjs/dist/types/internal/util/ArgumentOutOfRangeError.d.ts +21 -0
- package/dist/_types/rxjs/dist/types/internal/util/EmptyError.d.ts +23 -0
- package/dist/_types/rxjs/dist/types/internal/util/NotFoundError.d.ts +19 -0
- package/dist/_types/rxjs/dist/types/internal/util/ObjectUnsubscribedError.d.ts +20 -0
- package/dist/_types/rxjs/dist/types/internal/util/SequenceError.d.ts +19 -0
- package/dist/_types/rxjs/dist/types/internal/util/UnsubscriptionError.d.ts +16 -0
- package/dist/_types/rxjs/dist/types/internal/util/identity.d.ts +44 -0
- package/dist/_types/rxjs/dist/types/internal/util/isObservable.d.ts +8 -0
- package/dist/_types/rxjs/dist/types/internal/util/noop.d.ts +2 -0
- package/dist/_types/rxjs/dist/types/internal/util/pipe.d.ts +14 -0
- package/dist/index.cjs +3 -228
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -226
- package/dist/index.js.map +1 -1
- package/dist/interceptors/request-tracking.interceptor.d.ts +1 -1
- package/dist/interceptors/streaming.interceptor.d.ts +1 -1
- package/dist/interceptors/tracing.interceptor.d.ts +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction, ObservableInput, ObservedValueOf } from '../types';
|
|
2
|
+
export interface TimeoutConfig<T, O extends ObservableInput<unknown> = ObservableInput<T>, M = unknown> {
|
|
3
|
+
/**
|
|
4
|
+
* The time allowed between values from the source before timeout is triggered.
|
|
5
|
+
*/
|
|
6
|
+
each?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The relative time as a `number` in milliseconds, or a specific time as a `Date` object,
|
|
9
|
+
* by which the first value must arrive from the source before timeout is triggered.
|
|
10
|
+
*/
|
|
11
|
+
first?: number | Date;
|
|
12
|
+
/**
|
|
13
|
+
* The scheduler to use with time-related operations within this operator. Defaults to {@link asyncScheduler}
|
|
14
|
+
*/
|
|
15
|
+
scheduler?: SchedulerLike;
|
|
16
|
+
/**
|
|
17
|
+
* A factory used to create observable to switch to when timeout occurs. Provides
|
|
18
|
+
* a {@link TimeoutInfo} about the source observable's emissions and what delay or
|
|
19
|
+
* exact time triggered the timeout.
|
|
20
|
+
*/
|
|
21
|
+
with?: (info: TimeoutInfo<T, M>) => O;
|
|
22
|
+
/**
|
|
23
|
+
* Optional additional metadata you can provide to code that handles
|
|
24
|
+
* the timeout, will be provided through the {@link TimeoutError}.
|
|
25
|
+
* This can be used to help identify the source of a timeout or pass along
|
|
26
|
+
* other information related to the timeout.
|
|
27
|
+
*/
|
|
28
|
+
meta?: M;
|
|
29
|
+
}
|
|
30
|
+
export interface TimeoutInfo<T, M = unknown> {
|
|
31
|
+
/** Optional metadata that was provided to the timeout configuration. */
|
|
32
|
+
readonly meta: M;
|
|
33
|
+
/** The number of messages seen before the timeout */
|
|
34
|
+
readonly seen: number;
|
|
35
|
+
/** The last message seen */
|
|
36
|
+
readonly lastValue: T | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* An error emitted when a timeout occurs.
|
|
40
|
+
*/
|
|
41
|
+
export interface TimeoutError<T = unknown, M = unknown> extends Error {
|
|
42
|
+
/**
|
|
43
|
+
* The information provided to the error by the timeout
|
|
44
|
+
* operation that created the error. Will be `null` if
|
|
45
|
+
* used directly in non-RxJS code with an empty constructor.
|
|
46
|
+
* (Note that using this constructor directly is not recommended,
|
|
47
|
+
* you should create your own errors)
|
|
48
|
+
*/
|
|
49
|
+
info: TimeoutInfo<T, M> | null;
|
|
50
|
+
}
|
|
51
|
+
export interface TimeoutErrorCtor {
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Internal implementation detail. Do not construct error instances.
|
|
54
|
+
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
|
|
55
|
+
*/
|
|
56
|
+
new <T = unknown, M = unknown>(info?: TimeoutInfo<T, M>): TimeoutError<T, M>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An error thrown by the {@link timeout} operator.
|
|
60
|
+
*
|
|
61
|
+
* Provided so users can use as a type and do quality comparisons.
|
|
62
|
+
* We recommend you do not subclass this or create instances of this class directly.
|
|
63
|
+
* If you have need of a error representing a timeout, you should
|
|
64
|
+
* create your own error class and use that.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link timeout}
|
|
67
|
+
*
|
|
68
|
+
* @class TimeoutError
|
|
69
|
+
*/
|
|
70
|
+
export declare const TimeoutError: TimeoutErrorCtor;
|
|
71
|
+
/**
|
|
72
|
+
* If `with` is provided, this will return an observable that will switch to a different observable if the source
|
|
73
|
+
* does not push values within the specified time parameters.
|
|
74
|
+
*
|
|
75
|
+
* <span class="informal">The most flexible option for creating a timeout behavior.</span>
|
|
76
|
+
*
|
|
77
|
+
* The first thing to know about the configuration is if you do not provide a `with` property to the configuration,
|
|
78
|
+
* when timeout conditions are met, this operator will emit a {@link TimeoutError}. Otherwise, it will use the factory
|
|
79
|
+
* function provided by `with`, and switch your subscription to the result of that. Timeout conditions are provided by
|
|
80
|
+
* the settings in `first` and `each`.
|
|
81
|
+
*
|
|
82
|
+
* The `first` property can be either a `Date` for a specific time, a `number` for a time period relative to the
|
|
83
|
+
* point of subscription, or it can be skipped. This property is to check timeout conditions for the arrival of
|
|
84
|
+
* the first value from the source _only_. The timings of all subsequent values from the source will be checked
|
|
85
|
+
* against the time period provided by `each`, if it was provided.
|
|
86
|
+
*
|
|
87
|
+
* The `each` property can be either a `number` or skipped. If a value for `each` is provided, it represents the amount of
|
|
88
|
+
* time the resulting observable will wait between the arrival of values from the source before timing out. Note that if
|
|
89
|
+
* `first` is _not_ provided, the value from `each` will be used to check timeout conditions for the arrival of the first
|
|
90
|
+
* value and all subsequent values. If `first` _is_ provided, `each` will only be use to check all values after the first.
|
|
91
|
+
*
|
|
92
|
+
* ## Examples
|
|
93
|
+
*
|
|
94
|
+
* Emit a custom error if there is too much time between values
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* import { interval, timeout, throwError } from 'rxjs';
|
|
98
|
+
*
|
|
99
|
+
* class CustomTimeoutError extends Error {
|
|
100
|
+
* constructor() {
|
|
101
|
+
* super('It was too slow');
|
|
102
|
+
* this.name = 'CustomTimeoutError';
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* const slow$ = interval(900);
|
|
107
|
+
*
|
|
108
|
+
* slow$.pipe(
|
|
109
|
+
* timeout({
|
|
110
|
+
* each: 1000,
|
|
111
|
+
* with: () => throwError(() => new CustomTimeoutError())
|
|
112
|
+
* })
|
|
113
|
+
* )
|
|
114
|
+
* .subscribe({
|
|
115
|
+
* error: console.error
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* Switch to a faster observable if your source is slow.
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { interval, timeout } from 'rxjs';
|
|
123
|
+
*
|
|
124
|
+
* const slow$ = interval(900);
|
|
125
|
+
* const fast$ = interval(500);
|
|
126
|
+
*
|
|
127
|
+
* slow$.pipe(
|
|
128
|
+
* timeout({
|
|
129
|
+
* each: 1000,
|
|
130
|
+
* with: () => fast$,
|
|
131
|
+
* })
|
|
132
|
+
* )
|
|
133
|
+
* .subscribe(console.log);
|
|
134
|
+
* ```
|
|
135
|
+
* @param config The configuration for the timeout.
|
|
136
|
+
*/
|
|
137
|
+
export declare function timeout<T, O extends ObservableInput<unknown>, M = unknown>(config: TimeoutConfig<T, O, M> & {
|
|
138
|
+
with: (info: TimeoutInfo<T, M>) => O;
|
|
139
|
+
}): OperatorFunction<T, T | ObservedValueOf<O>>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns an observable that will error or switch to a different observable if the source does not push values
|
|
142
|
+
* within the specified time parameters.
|
|
143
|
+
*
|
|
144
|
+
* <span class="informal">The most flexible option for creating a timeout behavior.</span>
|
|
145
|
+
*
|
|
146
|
+
* The first thing to know about the configuration is if you do not provide a `with` property to the configuration,
|
|
147
|
+
* when timeout conditions are met, this operator will emit a {@link TimeoutError}. Otherwise, it will use the factory
|
|
148
|
+
* function provided by `with`, and switch your subscription to the result of that. Timeout conditions are provided by
|
|
149
|
+
* the settings in `first` and `each`.
|
|
150
|
+
*
|
|
151
|
+
* The `first` property can be either a `Date` for a specific time, a `number` for a time period relative to the
|
|
152
|
+
* point of subscription, or it can be skipped. This property is to check timeout conditions for the arrival of
|
|
153
|
+
* the first value from the source _only_. The timings of all subsequent values from the source will be checked
|
|
154
|
+
* against the time period provided by `each`, if it was provided.
|
|
155
|
+
*
|
|
156
|
+
* The `each` property can be either a `number` or skipped. If a value for `each` is provided, it represents the amount of
|
|
157
|
+
* time the resulting observable will wait between the arrival of values from the source before timing out. Note that if
|
|
158
|
+
* `first` is _not_ provided, the value from `each` will be used to check timeout conditions for the arrival of the first
|
|
159
|
+
* value and all subsequent values. If `first` _is_ provided, `each` will only be use to check all values after the first.
|
|
160
|
+
*
|
|
161
|
+
* ### Handling TimeoutErrors
|
|
162
|
+
*
|
|
163
|
+
* If no `with` property was provided, subscriptions to the resulting observable may emit an error of {@link TimeoutError}.
|
|
164
|
+
* The timeout error provides useful information you can examine when you're handling the error. The most common way to handle
|
|
165
|
+
* the error would be with {@link catchError}, although you could use {@link tap} or just the error handler in your `subscribe` call
|
|
166
|
+
* directly, if your error handling is only a side effect (such as notifying the user, or logging).
|
|
167
|
+
*
|
|
168
|
+
* In this case, you would check the error for `instanceof TimeoutError` to validate that the error was indeed from `timeout`, and
|
|
169
|
+
* not from some other source. If it's not from `timeout`, you should probably rethrow it if you're in a `catchError`.
|
|
170
|
+
*
|
|
171
|
+
* ## Examples
|
|
172
|
+
*
|
|
173
|
+
* Emit a {@link TimeoutError} if the first value, and _only_ the first value, does not arrive within 5 seconds
|
|
174
|
+
*
|
|
175
|
+
* ```ts
|
|
176
|
+
* import { interval, timeout } from 'rxjs';
|
|
177
|
+
*
|
|
178
|
+
* // A random interval that lasts between 0 and 10 seconds per tick
|
|
179
|
+
* const source$ = interval(Math.round(Math.random() * 10_000));
|
|
180
|
+
*
|
|
181
|
+
* source$.pipe(
|
|
182
|
+
* timeout({ first: 5_000 })
|
|
183
|
+
* )
|
|
184
|
+
* .subscribe({
|
|
185
|
+
* next: console.log,
|
|
186
|
+
* error: console.error
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* Emit a {@link TimeoutError} if the source waits longer than 5 seconds between any two values or the first value
|
|
191
|
+
* and subscription.
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* import { timer, timeout, expand } from 'rxjs';
|
|
195
|
+
*
|
|
196
|
+
* const getRandomTime = () => Math.round(Math.random() * 10_000);
|
|
197
|
+
*
|
|
198
|
+
* // An observable that waits a random amount of time between each delivered value
|
|
199
|
+
* const source$ = timer(getRandomTime())
|
|
200
|
+
* .pipe(expand(() => timer(getRandomTime())));
|
|
201
|
+
*
|
|
202
|
+
* source$
|
|
203
|
+
* .pipe(timeout({ each: 5_000 }))
|
|
204
|
+
* .subscribe({
|
|
205
|
+
* next: console.log,
|
|
206
|
+
* error: console.error
|
|
207
|
+
* });
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* Emit a {@link TimeoutError} if the source does not emit before 7 seconds, _or_ if the source waits longer than
|
|
211
|
+
* 5 seconds between any two values after the first.
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { timer, timeout, expand } from 'rxjs';
|
|
215
|
+
*
|
|
216
|
+
* const getRandomTime = () => Math.round(Math.random() * 10_000);
|
|
217
|
+
*
|
|
218
|
+
* // An observable that waits a random amount of time between each delivered value
|
|
219
|
+
* const source$ = timer(getRandomTime())
|
|
220
|
+
* .pipe(expand(() => timer(getRandomTime())));
|
|
221
|
+
*
|
|
222
|
+
* source$
|
|
223
|
+
* .pipe(timeout({ first: 7_000, each: 5_000 }))
|
|
224
|
+
* .subscribe({
|
|
225
|
+
* next: console.log,
|
|
226
|
+
* error: console.error
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export declare function timeout<T, M = unknown>(config: Omit<TimeoutConfig<T, any, M>, 'with'>): OperatorFunction<T, T>;
|
|
231
|
+
/**
|
|
232
|
+
* Returns an observable that will error if the source does not push its first value before the specified time passed as a `Date`.
|
|
233
|
+
* This is functionally the same as `timeout({ first: someDate })`.
|
|
234
|
+
*
|
|
235
|
+
* <span class="informal">Errors if the first value doesn't show up before the given date and time</span>
|
|
236
|
+
*
|
|
237
|
+
* 
|
|
238
|
+
*
|
|
239
|
+
* @param first The date to at which the resulting observable will timeout if the source observable
|
|
240
|
+
* does not emit at least one value.
|
|
241
|
+
* @param scheduler The scheduler to use. Defaults to {@link asyncScheduler}.
|
|
242
|
+
*/
|
|
243
|
+
export declare function timeout<T>(first: Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
|
|
244
|
+
/**
|
|
245
|
+
* Returns an observable that will error if the source does not push a value within the specified time in milliseconds.
|
|
246
|
+
* This is functionally the same as `timeout({ each: milliseconds })`.
|
|
247
|
+
*
|
|
248
|
+
* <span class="informal">Errors if it waits too long between any value</span>
|
|
249
|
+
*
|
|
250
|
+
* 
|
|
251
|
+
*
|
|
252
|
+
* @param each The time allowed between each pushed value from the source before the resulting observable
|
|
253
|
+
* will timeout.
|
|
254
|
+
* @param scheduler The scheduler to use. Defaults to {@link asyncScheduler}.
|
|
255
|
+
*/
|
|
256
|
+
export declare function timeout<T>(each: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
|
|
257
|
+
//# sourceMappingURL=timeout.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ObservableInput, OperatorFunction, SchedulerLike } from '../types';
|
|
2
|
+
/** @deprecated Replaced with {@link timeout}. Instead of `timeoutWith(someDate, a$, scheduler)`, use the configuration object
|
|
3
|
+
* `timeout({ first: someDate, with: () => a$, scheduler })`. Will be removed in v8. */
|
|
4
|
+
export declare function timeoutWith<T, R>(dueBy: Date, switchTo: ObservableInput<R>, scheduler?: SchedulerLike): OperatorFunction<T, T | R>;
|
|
5
|
+
/** @deprecated Replaced with {@link timeout}. Instead of `timeoutWith(100, a$, scheduler)`, use the configuration object
|
|
6
|
+
* `timeout({ each: 100, with: () => a$, scheduler })`. Will be removed in v8. */
|
|
7
|
+
export declare function timeoutWith<T, R>(waitFor: number, switchTo: ObservableInput<R>, scheduler?: SchedulerLike): OperatorFunction<T, T | R>;
|
|
8
|
+
//# sourceMappingURL=timeoutWith.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OperatorFunction, TimestampProvider, Timestamp } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Attaches a timestamp to each item emitted by an observable indicating when it was emitted
|
|
4
|
+
*
|
|
5
|
+
* The `timestamp` operator maps the *source* observable stream to an object of type
|
|
6
|
+
* `{value: T, timestamp: R}`. The properties are generically typed. The `value` property contains the value
|
|
7
|
+
* and type of the *source* observable. The `timestamp` is generated by the schedulers `now` function. By
|
|
8
|
+
* default, it uses the `asyncScheduler` which simply returns `Date.now()` (milliseconds since 1970/01/01
|
|
9
|
+
* 00:00:00:000) and therefore is of type `number`.
|
|
10
|
+
*
|
|
11
|
+
* 
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* In this example there is a timestamp attached to the document's click events
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { fromEvent, timestamp } from 'rxjs';
|
|
19
|
+
*
|
|
20
|
+
* const clickWithTimestamp = fromEvent(document, 'click').pipe(
|
|
21
|
+
* timestamp()
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* // Emits data of type { value: PointerEvent, timestamp: number }
|
|
25
|
+
* clickWithTimestamp.subscribe(data => {
|
|
26
|
+
* console.log(data);
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param timestampProvider An object with a `now()` method used to get the current timestamp.
|
|
31
|
+
* @return A function that returns an Observable that attaches a timestamp to
|
|
32
|
+
* each item emitted by the source Observable indicating when it was emitted.
|
|
33
|
+
*/
|
|
34
|
+
export declare function timestamp<T>(timestampProvider?: TimestampProvider): OperatorFunction<T, Timestamp<T>>;
|
|
35
|
+
//# sourceMappingURL=timestamp.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OperatorFunction } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Collects all source emissions and emits them as an array when the source completes.
|
|
4
|
+
*
|
|
5
|
+
* <span class="informal">Get all values inside an array when the source completes</span>
|
|
6
|
+
*
|
|
7
|
+
* 
|
|
8
|
+
*
|
|
9
|
+
* `toArray` will wait until the source Observable completes before emitting
|
|
10
|
+
* the array containing all emissions. When the source Observable errors no
|
|
11
|
+
* array will be emitted.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { interval, take, toArray } from 'rxjs';
|
|
17
|
+
*
|
|
18
|
+
* const source = interval(1000);
|
|
19
|
+
* const example = source.pipe(
|
|
20
|
+
* take(10),
|
|
21
|
+
* toArray()
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* example.subscribe(value => console.log(value));
|
|
25
|
+
*
|
|
26
|
+
* // output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @return A function that returns an Observable that emits an array of items
|
|
30
|
+
* emitted by the source Observable when source completes.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toArray<T>(): OperatorFunction<T, T[]>;
|
|
33
|
+
//# sourceMappingURL=toArray.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Observable } from '../Observable';
|
|
2
|
+
import { OperatorFunction, ObservableInput } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Branch out the source Observable values as a nested Observable whenever
|
|
5
|
+
* `windowBoundaries` emits.
|
|
6
|
+
*
|
|
7
|
+
* <span class="informal">It's like {@link buffer}, but emits a nested Observable
|
|
8
|
+
* instead of an array.</span>
|
|
9
|
+
*
|
|
10
|
+
* 
|
|
11
|
+
*
|
|
12
|
+
* Returns an Observable that emits windows of items it collects from the source
|
|
13
|
+
* Observable. The output Observable emits connected, non-overlapping
|
|
14
|
+
* windows. It emits the current window and opens a new one whenever the
|
|
15
|
+
* `windowBoundaries` emits an item. `windowBoundaries` can be any type that
|
|
16
|
+
* `ObservableInput` accepts. It internally gets converted to an Observable.
|
|
17
|
+
* Because each window is an Observable, the output is a higher-order Observable.
|
|
18
|
+
*
|
|
19
|
+
* ## Example
|
|
20
|
+
*
|
|
21
|
+
* In every window of 1 second each, emit at most 2 click events
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { fromEvent, interval, window, map, take, mergeAll } from 'rxjs';
|
|
25
|
+
*
|
|
26
|
+
* const clicks = fromEvent(document, 'click');
|
|
27
|
+
* const sec = interval(1000);
|
|
28
|
+
* const result = clicks.pipe(
|
|
29
|
+
* window(sec),
|
|
30
|
+
* map(win => win.pipe(take(2))), // take at most 2 emissions from each window
|
|
31
|
+
* mergeAll() // flatten the Observable-of-Observables
|
|
32
|
+
* );
|
|
33
|
+
* result.subscribe(x => console.log(x));
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @see {@link windowCount}
|
|
37
|
+
* @see {@link windowTime}
|
|
38
|
+
* @see {@link windowToggle}
|
|
39
|
+
* @see {@link windowWhen}
|
|
40
|
+
* @see {@link buffer}
|
|
41
|
+
*
|
|
42
|
+
* @param windowBoundaries An `ObservableInput` that completes the
|
|
43
|
+
* previous window and starts a new window.
|
|
44
|
+
* @return A function that returns an Observable of windows, which are
|
|
45
|
+
* Observables emitting values of the source Observable.
|
|
46
|
+
*/
|
|
47
|
+
export declare function window<T>(windowBoundaries: ObservableInput<any>): OperatorFunction<T, Observable<T>>;
|
|
48
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Observable } from '../Observable';
|
|
2
|
+
import { OperatorFunction } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Branch out the source Observable values as a nested Observable with each
|
|
5
|
+
* nested Observable emitting at most `windowSize` values.
|
|
6
|
+
*
|
|
7
|
+
* <span class="informal">It's like {@link bufferCount}, but emits a nested
|
|
8
|
+
* Observable instead of an array.</span>
|
|
9
|
+
*
|
|
10
|
+
* 
|
|
11
|
+
*
|
|
12
|
+
* Returns an Observable that emits windows of items it collects from the source
|
|
13
|
+
* Observable. The output Observable emits windows every `startWindowEvery`
|
|
14
|
+
* items, each containing no more than `windowSize` items. When the source
|
|
15
|
+
* Observable completes or encounters an error, the output Observable emits
|
|
16
|
+
* the current window and propagates the notification from the source
|
|
17
|
+
* Observable. If `startWindowEvery` is not provided, then new windows are
|
|
18
|
+
* started immediately at the start of the source and when each window completes
|
|
19
|
+
* with size `windowSize`.
|
|
20
|
+
*
|
|
21
|
+
* ## Examples
|
|
22
|
+
*
|
|
23
|
+
* Ignore every 3rd click event, starting from the first one
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { fromEvent, windowCount, map, skip, mergeAll } from 'rxjs';
|
|
27
|
+
*
|
|
28
|
+
* const clicks = fromEvent(document, 'click');
|
|
29
|
+
* const result = clicks.pipe(
|
|
30
|
+
* windowCount(3),
|
|
31
|
+
* map(win => win.pipe(skip(1))), // skip first of every 3 clicks
|
|
32
|
+
* mergeAll() // flatten the Observable-of-Observables
|
|
33
|
+
* );
|
|
34
|
+
* result.subscribe(x => console.log(x));
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Ignore every 3rd click event, starting from the third one
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { fromEvent, windowCount, mergeAll } from 'rxjs';
|
|
41
|
+
*
|
|
42
|
+
* const clicks = fromEvent(document, 'click');
|
|
43
|
+
* const result = clicks.pipe(
|
|
44
|
+
* windowCount(2, 3),
|
|
45
|
+
* mergeAll() // flatten the Observable-of-Observables
|
|
46
|
+
* );
|
|
47
|
+
* result.subscribe(x => console.log(x));
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see {@link window}
|
|
51
|
+
* @see {@link windowTime}
|
|
52
|
+
* @see {@link windowToggle}
|
|
53
|
+
* @see {@link windowWhen}
|
|
54
|
+
* @see {@link bufferCount}
|
|
55
|
+
*
|
|
56
|
+
* @param {number} windowSize The maximum number of values emitted by each
|
|
57
|
+
* window.
|
|
58
|
+
* @param {number} [startWindowEvery] Interval at which to start a new window.
|
|
59
|
+
* For example if `startWindowEvery` is `2`, then a new window will be started
|
|
60
|
+
* on every other value from the source. A new window is started at the
|
|
61
|
+
* beginning of the source by default.
|
|
62
|
+
* @return A function that returns an Observable of windows, which in turn are
|
|
63
|
+
* Observable of values.
|
|
64
|
+
*/
|
|
65
|
+
export declare function windowCount<T>(windowSize: number, startWindowEvery?: number): OperatorFunction<T, Observable<T>>;
|
|
66
|
+
//# sourceMappingURL=windowCount.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Observable } from '../Observable';
|
|
2
|
+
import { OperatorFunction, SchedulerLike } from '../types';
|
|
3
|
+
export declare function windowTime<T>(windowTimeSpan: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
|
|
4
|
+
export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
|
|
5
|
+
export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number | null | void, maxWindowSize: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
|
|
6
|
+
//# sourceMappingURL=windowTime.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Observable } from '../Observable';
|
|
2
|
+
import { ObservableInput, OperatorFunction } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Branch out the source Observable values as a nested Observable starting from
|
|
5
|
+
* an emission from `openings` and ending when the output of `closingSelector`
|
|
6
|
+
* emits.
|
|
7
|
+
*
|
|
8
|
+
* <span class="informal">It's like {@link bufferToggle}, but emits a nested
|
|
9
|
+
* Observable instead of an array.</span>
|
|
10
|
+
*
|
|
11
|
+
* 
|
|
12
|
+
*
|
|
13
|
+
* Returns an Observable that emits windows of items it collects from the source
|
|
14
|
+
* Observable. The output Observable emits windows that contain those items
|
|
15
|
+
* emitted by the source Observable between the time when the `openings`
|
|
16
|
+
* Observable emits an item and when the Observable returned by
|
|
17
|
+
* `closingSelector` emits an item.
|
|
18
|
+
*
|
|
19
|
+
* ## Example
|
|
20
|
+
*
|
|
21
|
+
* Every other second, emit the click events from the next 500ms
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { fromEvent, interval, windowToggle, EMPTY, mergeAll } from 'rxjs';
|
|
25
|
+
*
|
|
26
|
+
* const clicks = fromEvent(document, 'click');
|
|
27
|
+
* const openings = interval(1000);
|
|
28
|
+
* const result = clicks.pipe(
|
|
29
|
+
* windowToggle(openings, i => i % 2 ? interval(500) : EMPTY),
|
|
30
|
+
* mergeAll()
|
|
31
|
+
* );
|
|
32
|
+
* result.subscribe(x => console.log(x));
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see {@link window}
|
|
36
|
+
* @see {@link windowCount}
|
|
37
|
+
* @see {@link windowTime}
|
|
38
|
+
* @see {@link windowWhen}
|
|
39
|
+
* @see {@link bufferToggle}
|
|
40
|
+
*
|
|
41
|
+
* @param {Observable<O>} openings An observable of notifications to start new
|
|
42
|
+
* windows.
|
|
43
|
+
* @param {function(value: O): Observable} closingSelector A function that takes
|
|
44
|
+
* the value emitted by the `openings` observable and returns an Observable,
|
|
45
|
+
* which, when it emits a next notification, signals that the
|
|
46
|
+
* associated window should complete.
|
|
47
|
+
* @return A function that returns an Observable of windows, which in turn are
|
|
48
|
+
* Observables.
|
|
49
|
+
*/
|
|
50
|
+
export declare function windowToggle<T, O>(openings: ObservableInput<O>, closingSelector: (openValue: O) => ObservableInput<any>): OperatorFunction<T, Observable<T>>;
|
|
51
|
+
//# sourceMappingURL=windowToggle.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Observable } from '../Observable';
|
|
2
|
+
import { ObservableInput, OperatorFunction } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Branch out the source Observable values as a nested Observable using a
|
|
5
|
+
* factory function of closing Observables to determine when to start a new
|
|
6
|
+
* window.
|
|
7
|
+
*
|
|
8
|
+
* <span class="informal">It's like {@link bufferWhen}, but emits a nested
|
|
9
|
+
* Observable instead of an array.</span>
|
|
10
|
+
*
|
|
11
|
+
* 
|
|
12
|
+
*
|
|
13
|
+
* Returns an Observable that emits windows of items it collects from the source
|
|
14
|
+
* Observable. The output Observable emits connected, non-overlapping windows.
|
|
15
|
+
* It emits the current window and opens a new one whenever the Observable
|
|
16
|
+
* produced by the specified `closingSelector` function emits an item. The first
|
|
17
|
+
* window is opened immediately when subscribing to the output Observable.
|
|
18
|
+
*
|
|
19
|
+
* ## Example
|
|
20
|
+
*
|
|
21
|
+
* Emit only the first two clicks events in every window of [1-5] random seconds
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { fromEvent, windowWhen, interval, map, take, mergeAll } from 'rxjs';
|
|
25
|
+
*
|
|
26
|
+
* const clicks = fromEvent(document, 'click');
|
|
27
|
+
* const result = clicks.pipe(
|
|
28
|
+
* windowWhen(() => interval(1000 + Math.random() * 4000)),
|
|
29
|
+
* map(win => win.pipe(take(2))), // take at most 2 emissions from each window
|
|
30
|
+
* mergeAll() // flatten the Observable-of-Observables
|
|
31
|
+
* );
|
|
32
|
+
* result.subscribe(x => console.log(x));
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see {@link window}
|
|
36
|
+
* @see {@link windowCount}
|
|
37
|
+
* @see {@link windowTime}
|
|
38
|
+
* @see {@link windowToggle}
|
|
39
|
+
* @see {@link bufferWhen}
|
|
40
|
+
*
|
|
41
|
+
* @param {function(): Observable} closingSelector A function that takes no
|
|
42
|
+
* arguments and returns an Observable that signals (on either `next` or
|
|
43
|
+
* `complete`) when to close the previous window and start a new one.
|
|
44
|
+
* @return A function that returns an Observable of windows, which in turn are
|
|
45
|
+
* Observables.
|
|
46
|
+
*/
|
|
47
|
+
export declare function windowWhen<T>(closingSelector: () => ObservableInput<any>): OperatorFunction<T, Observable<T>>;
|
|
48
|
+
//# sourceMappingURL=windowWhen.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OperatorFunction, ObservableInputTuple } from '../types';
|
|
2
|
+
export declare function withLatestFrom<T, O extends unknown[]>(...inputs: [...ObservableInputTuple<O>]): OperatorFunction<T, [T, ...O]>;
|
|
3
|
+
export declare function withLatestFrom<T, O extends unknown[], R>(...inputs: [...ObservableInputTuple<O>, (...value: [T, ...O]) => R]): OperatorFunction<T, R>;
|
|
4
|
+
//# sourceMappingURL=withLatestFrom.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OperatorFunction, ObservableInput } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Collects all observable inner sources from the source, once the source completes,
|
|
4
|
+
* it will subscribe to all inner sources, combining their values by index and emitting
|
|
5
|
+
* them.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link zipWith}
|
|
8
|
+
* @see {@link zip}
|
|
9
|
+
*/
|
|
10
|
+
export declare function zipAll<T>(): OperatorFunction<ObservableInput<T>, T[]>;
|
|
11
|
+
export declare function zipAll<T>(): OperatorFunction<any, T[]>;
|
|
12
|
+
export declare function zipAll<T, R>(project: (...values: T[]) => R): OperatorFunction<ObservableInput<T>, R>;
|
|
13
|
+
export declare function zipAll<R>(project: (...values: Array<any>) => R): OperatorFunction<any, R>;
|
|
14
|
+
//# sourceMappingURL=zipAll.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ObservableInputTuple, OperatorFunction, Cons } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Subscribes to the source, and the observable inputs provided as arguments, and combines their values, by index, into arrays.
|
|
4
|
+
*
|
|
5
|
+
* What is meant by "combine by index": The first value from each will be made into a single array, then emitted,
|
|
6
|
+
* then the second value from each will be combined into a single array and emitted, then the third value
|
|
7
|
+
* from each will be combined into a single array and emitted, and so on.
|
|
8
|
+
*
|
|
9
|
+
* This will continue until it is no longer able to combine values of the same index into an array.
|
|
10
|
+
*
|
|
11
|
+
* After the last value from any one completed source is emitted in an array, the resulting observable will complete,
|
|
12
|
+
* as there is no way to continue "zipping" values together by index.
|
|
13
|
+
*
|
|
14
|
+
* Use-cases for this operator are limited. There are memory concerns if one of the streams is emitting
|
|
15
|
+
* values at a much faster rate than the others. Usage should likely be limited to streams that emit
|
|
16
|
+
* at a similar pace, or finite streams of known length.
|
|
17
|
+
*
|
|
18
|
+
* In many cases, authors want `combineLatestWith` and not `zipWith`.
|
|
19
|
+
*
|
|
20
|
+
* @param otherInputs other observable inputs to collate values from.
|
|
21
|
+
* @return A function that returns an Observable that emits items by index
|
|
22
|
+
* combined from the source Observable and provided Observables, in form of an
|
|
23
|
+
* array.
|
|
24
|
+
*/
|
|
25
|
+
export declare function zipWith<T, A extends readonly unknown[]>(...otherInputs: [...ObservableInputTuple<A>]): OperatorFunction<T, Cons<T, A>>;
|
|
26
|
+
//# sourceMappingURL=zipWith.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ObservableInput, SchedulerLike } from '../types';
|
|
2
|
+
import { Observable } from '../Observable';
|
|
3
|
+
/**
|
|
4
|
+
* Converts from a common {@link ObservableInput} type to an observable where subscription and emissions
|
|
5
|
+
* are scheduled on the provided scheduler.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link from}
|
|
8
|
+
* @see {@link of}
|
|
9
|
+
*
|
|
10
|
+
* @param input The observable, array, promise, iterable, etc you would like to schedule
|
|
11
|
+
* @param scheduler The scheduler to use to schedule the subscription and emissions from
|
|
12
|
+
* the returned observable.
|
|
13
|
+
*/
|
|
14
|
+
export declare function scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T>;
|
|
15
|
+
//# sourceMappingURL=scheduled.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Scheduler } from '../Scheduler';
|
|
2
|
+
import { Subscription } from '../Subscription';
|
|
3
|
+
import { SchedulerAction } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* A unit of work to be executed in a `scheduler`. An action is typically
|
|
6
|
+
* created from within a {@link SchedulerLike} and an RxJS user does not need to concern
|
|
7
|
+
* themselves about creating and manipulating an Action.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* class Action<T> extends Subscription {
|
|
11
|
+
* new (scheduler: Scheduler, work: (state?: T) => void);
|
|
12
|
+
* schedule(state?: T, delay: number = 0): Subscription;
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @class Action<T>
|
|
17
|
+
*/
|
|
18
|
+
export declare class Action<T> extends Subscription {
|
|
19
|
+
constructor(scheduler: Scheduler, work: (this: SchedulerAction<T>, state?: T) => void);
|
|
20
|
+
/**
|
|
21
|
+
* Schedules this action on its parent {@link SchedulerLike} for execution. May be passed
|
|
22
|
+
* some context object, `state`. May happen at some point in the future,
|
|
23
|
+
* according to the `delay` parameter, if specified.
|
|
24
|
+
* @param {T} [state] Some contextual data that the `work` function uses when
|
|
25
|
+
* called by the Scheduler.
|
|
26
|
+
* @param {number} [delay] Time to wait before executing the work, where the
|
|
27
|
+
* time unit is implicit and defined by the Scheduler.
|
|
28
|
+
* @return {void}
|
|
29
|
+
*/
|
|
30
|
+
schedule(state?: T, delay?: number): Subscription;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Action.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AsyncAction } from './AsyncAction';
|
|
2
|
+
import { AsyncScheduler } from './AsyncScheduler';
|
|
3
|
+
export declare class AnimationFrameScheduler extends AsyncScheduler {
|
|
4
|
+
flush(action?: AsyncAction<any>): void;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AnimationFrameScheduler.d.ts.map
|