flinker 1.0.0 → 1.0.5
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/dist/RX.d.ts +22 -0
- package/dist/RXObserver.d.ts +33 -0
- package/dist/RXOperator.d.ts +133 -0
- package/dist/RXPipeline.d.ts +14 -0
- package/dist/RXPublisher.d.ts +153 -0
- package/dist/RXSubscriber.d.ts +30 -0
- package/dist/cjs/RX.js +41 -0
- package/dist/cjs/RXObserver.js +255 -0
- package/dist/cjs/RXOperator.js +484 -0
- package/dist/cjs/RXPipeline.js +27 -0
- package/dist/cjs/RXPublisher.js +733 -0
- package/dist/cjs/RXSubscriber.js +77 -0
- package/dist/cjs/index.js +50 -0
- package/dist/esm/RX.js +38 -0
- package/dist/esm/RXObserver.js +249 -0
- package/dist/esm/RXOperator.js +481 -0
- package/dist/esm/RXPipeline.js +24 -0
- package/dist/esm/RXPublisher.js +730 -0
- package/dist/esm/RXSubscriber.js +74 -0
- package/dist/esm/index.js +7 -0
- package/dist/index.d.ts +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.RXReplaceError = exports.RXDebounce = exports.RXRemoveDuplicates = exports.RXSkipNullable = exports.RXSkipFirst = exports.RXSpread = exports.RXFilter = exports.RXParallel = exports.RXSequent = exports.RXForEach = exports.RXFlatMap = exports.RXMap = exports.RXOperator = void 0;
|
|
19
|
+
var RXPublisher_js_1 = require("./RXPublisher.js");
|
|
20
|
+
var RXSubscriber_js_1 = require("./RXSubscriber.js");
|
|
21
|
+
var RXOperator = /** @class */ (function () {
|
|
22
|
+
function RXOperator(pipeline) {
|
|
23
|
+
this.type = 'operator';
|
|
24
|
+
//--------------------------------------
|
|
25
|
+
// isComplete
|
|
26
|
+
//--------------------------------------
|
|
27
|
+
this._isComplete = false;
|
|
28
|
+
this.pipeline = pipeline;
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(RXOperator.prototype, "isComplete", {
|
|
31
|
+
get: function () { return this._isComplete; },
|
|
32
|
+
enumerable: false,
|
|
33
|
+
configurable: true
|
|
34
|
+
});
|
|
35
|
+
//--------------------------------------
|
|
36
|
+
// RXSender Protocol
|
|
37
|
+
//--------------------------------------
|
|
38
|
+
RXOperator.prototype.send = function (value, broadcast) {
|
|
39
|
+
var _a;
|
|
40
|
+
if (!this.isComplete) {
|
|
41
|
+
(_a = this.child) === null || _a === void 0 ? void 0 : _a.send(value, broadcast);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
RXOperator.prototype.sendError = function (e, broadcast) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (!this.isComplete) {
|
|
47
|
+
(_a = this.child) === null || _a === void 0 ? void 0 : _a.sendError(e, broadcast);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
RXOperator.prototype.sendComplete = function (broadcast) {
|
|
51
|
+
var _a;
|
|
52
|
+
if (!this.isComplete) {
|
|
53
|
+
this._isComplete = true;
|
|
54
|
+
(_a = this.child) === null || _a === void 0 ? void 0 : _a.sendComplete(broadcast);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//--------------------------------------
|
|
58
|
+
// OPERATORS
|
|
59
|
+
//--------------------------------------
|
|
60
|
+
RXOperator.prototype.skipFirst = function () {
|
|
61
|
+
return this.addChild(new RXSkipFirst(this.pipeline));
|
|
62
|
+
};
|
|
63
|
+
RXOperator.prototype.skipNullable = function () {
|
|
64
|
+
return this.addChild(new RXSkipNullable(this.pipeline));
|
|
65
|
+
};
|
|
66
|
+
RXOperator.prototype.removeDuplicates = function (value) {
|
|
67
|
+
return this.addChild(new RXRemoveDuplicates(this.pipeline, value));
|
|
68
|
+
};
|
|
69
|
+
RXOperator.prototype.debounce = function (ms) {
|
|
70
|
+
return this.addChild(new RXDebounce(this.pipeline, ms));
|
|
71
|
+
};
|
|
72
|
+
RXOperator.prototype.map = function (f) {
|
|
73
|
+
return this.addChild(new RXMap(this.pipeline, f));
|
|
74
|
+
};
|
|
75
|
+
RXOperator.prototype.flatMap = function (f) {
|
|
76
|
+
return this.addChild(new RXFlatMap(this.pipeline, f));
|
|
77
|
+
};
|
|
78
|
+
RXOperator.prototype.forEach = function (f) {
|
|
79
|
+
return this.addChild(new RXForEach(this.pipeline, f));
|
|
80
|
+
};
|
|
81
|
+
RXOperator.prototype.sequent = function (f) {
|
|
82
|
+
return this.addChild(new RXSequent(this.pipeline, f));
|
|
83
|
+
};
|
|
84
|
+
RXOperator.prototype.parallel = function (f) {
|
|
85
|
+
return this.addChild(new RXParallel(this.pipeline, f));
|
|
86
|
+
};
|
|
87
|
+
RXOperator.prototype.filter = function (predicate) {
|
|
88
|
+
return this.addChild(new RXFilter(this.pipeline, predicate));
|
|
89
|
+
};
|
|
90
|
+
RXOperator.prototype.spread = function () {
|
|
91
|
+
return this.addChild(new RXSpread(this.pipeline));
|
|
92
|
+
};
|
|
93
|
+
RXOperator.prototype.replaceError = function (replaceWith) {
|
|
94
|
+
return this.addChild(new RXReplaceError(this.pipeline, replaceWith));
|
|
95
|
+
};
|
|
96
|
+
RXOperator.prototype.addChild = function (op) {
|
|
97
|
+
this.child = op;
|
|
98
|
+
return op;
|
|
99
|
+
};
|
|
100
|
+
//--------------------------------------
|
|
101
|
+
// Output
|
|
102
|
+
//--------------------------------------
|
|
103
|
+
RXOperator.prototype.fork = function () {
|
|
104
|
+
var subscriber = new RXSubscriber_js_1.RXSubscriber(this.pipeline);
|
|
105
|
+
this.child = subscriber;
|
|
106
|
+
var dispatcher = new RXPublisher_js_1.RXEmitter();
|
|
107
|
+
subscriber.onReceive(function (v) { dispatcher.send(v); });
|
|
108
|
+
subscriber.onError(function (e) { dispatcher.sendError(e); });
|
|
109
|
+
subscriber.onComplete(function () { dispatcher.sendComplete(); });
|
|
110
|
+
subscriber.subscribe();
|
|
111
|
+
return dispatcher.asObservable;
|
|
112
|
+
};
|
|
113
|
+
RXOperator.prototype.onReceive = function (f) {
|
|
114
|
+
var subscriber = new RXSubscriber_js_1.RXSubscriber(this.pipeline);
|
|
115
|
+
this.child = subscriber;
|
|
116
|
+
return subscriber.onReceive(f);
|
|
117
|
+
};
|
|
118
|
+
RXOperator.prototype.onError = function (f) {
|
|
119
|
+
var subscriber = new RXSubscriber_js_1.RXSubscriber(this.pipeline);
|
|
120
|
+
this.child = subscriber;
|
|
121
|
+
return subscriber.onError(f);
|
|
122
|
+
};
|
|
123
|
+
RXOperator.prototype.onComplete = function (f) {
|
|
124
|
+
var subscriber = new RXSubscriber_js_1.RXSubscriber(this.pipeline);
|
|
125
|
+
this.child = subscriber;
|
|
126
|
+
return subscriber.onComplete(f);
|
|
127
|
+
};
|
|
128
|
+
return RXOperator;
|
|
129
|
+
}());
|
|
130
|
+
exports.RXOperator = RXOperator;
|
|
131
|
+
//--------------------------------------
|
|
132
|
+
// RXMap
|
|
133
|
+
//--------------------------------------
|
|
134
|
+
var RXMap = /** @class */ (function (_super) {
|
|
135
|
+
__extends(RXMap, _super);
|
|
136
|
+
function RXMap(pipe, mapper) {
|
|
137
|
+
var _this = _super.call(this, pipe) || this;
|
|
138
|
+
_this.mapper = mapper;
|
|
139
|
+
return _this;
|
|
140
|
+
}
|
|
141
|
+
RXMap.prototype.send = function (value, broadcast) {
|
|
142
|
+
var newValue = this.mapper(value);
|
|
143
|
+
_super.prototype.send.call(this, newValue, broadcast);
|
|
144
|
+
};
|
|
145
|
+
return RXMap;
|
|
146
|
+
}(RXOperator));
|
|
147
|
+
exports.RXMap = RXMap;
|
|
148
|
+
//--------------------------------------
|
|
149
|
+
// RXFlatMap
|
|
150
|
+
//--------------------------------------
|
|
151
|
+
var RXFlatMap = /** @class */ (function (_super) {
|
|
152
|
+
__extends(RXFlatMap, _super);
|
|
153
|
+
function RXFlatMap(pipe, mapper) {
|
|
154
|
+
var _this = _super.call(this, pipe) || this;
|
|
155
|
+
_this.mapper = mapper;
|
|
156
|
+
return _this;
|
|
157
|
+
}
|
|
158
|
+
RXFlatMap.prototype.send = function (value, broadcast) {
|
|
159
|
+
var _this = this;
|
|
160
|
+
if (this.isComplete)
|
|
161
|
+
return;
|
|
162
|
+
this.mapper(value).pipe()
|
|
163
|
+
.onReceive(function (v) {
|
|
164
|
+
_super.prototype.send.call(_this, v, broadcast);
|
|
165
|
+
})
|
|
166
|
+
.onError(function (e) {
|
|
167
|
+
_this.sendError(e, broadcast);
|
|
168
|
+
})
|
|
169
|
+
.subscribe();
|
|
170
|
+
};
|
|
171
|
+
return RXFlatMap;
|
|
172
|
+
}(RXOperator));
|
|
173
|
+
exports.RXFlatMap = RXFlatMap;
|
|
174
|
+
var RXForEach = /** @class */ (function (_super) {
|
|
175
|
+
__extends(RXForEach, _super);
|
|
176
|
+
function RXForEach(pipe, mapper) {
|
|
177
|
+
var _this = _super.call(this, pipe) || this;
|
|
178
|
+
_this.buffer = Array();
|
|
179
|
+
_this.willComplete = false;
|
|
180
|
+
_this.willCompleteBroadcast = false;
|
|
181
|
+
_this.curOp = new RXPublisher_js_1.RXJustComplete();
|
|
182
|
+
_this.mapper = mapper;
|
|
183
|
+
return _this;
|
|
184
|
+
}
|
|
185
|
+
RXForEach.prototype.send = function (value, broadcast) {
|
|
186
|
+
this.buffer.push({ hasError: false, value: value, broadcast: broadcast });
|
|
187
|
+
this.processNext();
|
|
188
|
+
};
|
|
189
|
+
RXForEach.prototype.sendError = function (error, broadcast) {
|
|
190
|
+
this.buffer.push({ hasError: true, error: error, broadcast: broadcast });
|
|
191
|
+
this.processNext();
|
|
192
|
+
};
|
|
193
|
+
RXForEach.prototype.sendComplete = function (broadcast) {
|
|
194
|
+
this.willComplete = true;
|
|
195
|
+
this.willCompleteBroadcast || (this.willCompleteBroadcast = broadcast);
|
|
196
|
+
this.processNext();
|
|
197
|
+
};
|
|
198
|
+
RXForEach.prototype.processNext = function () {
|
|
199
|
+
var _this = this;
|
|
200
|
+
if (!this.curOp.isComplete)
|
|
201
|
+
return;
|
|
202
|
+
var notification = this.buffer.shift();
|
|
203
|
+
if (notification) {
|
|
204
|
+
if (notification.hasError) {
|
|
205
|
+
_super.prototype.sendError.call(this, notification.error, notification.broadcast);
|
|
206
|
+
this.processNext();
|
|
207
|
+
}
|
|
208
|
+
else if (notification.value !== undefined) {
|
|
209
|
+
this.curOp = this.mapper(notification.value);
|
|
210
|
+
this.curOp.pipe()
|
|
211
|
+
.onReceive(function (v) {
|
|
212
|
+
_super.prototype.send.call(_this, v, notification.broadcast);
|
|
213
|
+
})
|
|
214
|
+
.onError(function (e) {
|
|
215
|
+
_super.prototype.sendError.call(_this, e, notification.broadcast);
|
|
216
|
+
})
|
|
217
|
+
.onComplete(function () { _this.processNext(); })
|
|
218
|
+
.subscribe();
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
this.processNext();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
if (this.willComplete)
|
|
226
|
+
_super.prototype.sendComplete.call(this, this.willCompleteBroadcast);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
return RXForEach;
|
|
230
|
+
}(RXOperator));
|
|
231
|
+
exports.RXForEach = RXForEach;
|
|
232
|
+
var RXSequent = /** @class */ (function (_super) {
|
|
233
|
+
__extends(RXSequent, _super);
|
|
234
|
+
function RXSequent(pipe, mapper) {
|
|
235
|
+
var _this = _super.call(this, pipe) || this;
|
|
236
|
+
_this.buffer = Array();
|
|
237
|
+
_this.willComplete = false;
|
|
238
|
+
_this.willCompleteBroadcast = false;
|
|
239
|
+
_this.curOp = new RXPublisher_js_1.RXJustComplete();
|
|
240
|
+
_this.mapper = mapper;
|
|
241
|
+
return _this;
|
|
242
|
+
}
|
|
243
|
+
RXSequent.prototype.send = function (value, broadcast) {
|
|
244
|
+
this.buffer.push({ hasError: false, value: value, broadcast: broadcast });
|
|
245
|
+
this.processNext();
|
|
246
|
+
};
|
|
247
|
+
RXSequent.prototype.sendError = function (error, broadcast) {
|
|
248
|
+
this.buffer.push({ hasError: true, error: error, broadcast: broadcast });
|
|
249
|
+
this.processNext();
|
|
250
|
+
};
|
|
251
|
+
RXSequent.prototype.sendComplete = function (broadcast) {
|
|
252
|
+
this.willComplete = true;
|
|
253
|
+
this.willCompleteBroadcast || (this.willCompleteBroadcast = broadcast);
|
|
254
|
+
this.processNext();
|
|
255
|
+
};
|
|
256
|
+
RXSequent.prototype.processNext = function () {
|
|
257
|
+
var _this = this;
|
|
258
|
+
if (!this.curOp.isComplete)
|
|
259
|
+
return;
|
|
260
|
+
var notification = this.buffer.shift();
|
|
261
|
+
if (notification) {
|
|
262
|
+
if (notification.hasError) {
|
|
263
|
+
_super.prototype.sendError.call(this, notification.error, notification.broadcast);
|
|
264
|
+
this.processNext();
|
|
265
|
+
}
|
|
266
|
+
else if (notification.value !== undefined) {
|
|
267
|
+
this.curOp = this.mapper(notification.value);
|
|
268
|
+
this.curOp.pipe()
|
|
269
|
+
.onReceive(function (v) {
|
|
270
|
+
_super.prototype.send.call(_this, v, notification.broadcast);
|
|
271
|
+
})
|
|
272
|
+
.onError(function (e) {
|
|
273
|
+
_super.prototype.sendError.call(_this, e, notification.broadcast);
|
|
274
|
+
})
|
|
275
|
+
.onComplete(function () { _this.processNext(); })
|
|
276
|
+
.subscribe();
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
this.processNext();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
if (this.willComplete)
|
|
284
|
+
_super.prototype.sendComplete.call(this, this.willCompleteBroadcast);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
return RXSequent;
|
|
288
|
+
}(RXOperator));
|
|
289
|
+
exports.RXSequent = RXSequent;
|
|
290
|
+
//--------------------------------------
|
|
291
|
+
// RXParallel
|
|
292
|
+
//--------------------------------------
|
|
293
|
+
var RXParallel = /** @class */ (function (_super) {
|
|
294
|
+
__extends(RXParallel, _super);
|
|
295
|
+
function RXParallel(pipe, mapper) {
|
|
296
|
+
var _this = _super.call(this, pipe) || this;
|
|
297
|
+
_this.willComplete = false;
|
|
298
|
+
_this.willCompleteBroadcast = false;
|
|
299
|
+
_this.activeOperations = 0;
|
|
300
|
+
_this.mapper = mapper;
|
|
301
|
+
return _this;
|
|
302
|
+
}
|
|
303
|
+
RXParallel.prototype.send = function (value, broadcast) {
|
|
304
|
+
var _this = this;
|
|
305
|
+
this.activeOperations++;
|
|
306
|
+
this.mapper(value).pipe()
|
|
307
|
+
.onReceive(function (v) {
|
|
308
|
+
_super.prototype.send.call(_this, v, broadcast);
|
|
309
|
+
})
|
|
310
|
+
.onError(function (e) {
|
|
311
|
+
_super.prototype.sendError.call(_this, e, broadcast);
|
|
312
|
+
})
|
|
313
|
+
.onComplete(function () {
|
|
314
|
+
_this.activeOperations--;
|
|
315
|
+
if (_this.activeOperations === 0 && _this.willComplete)
|
|
316
|
+
_super.prototype.sendComplete.call(_this, _this.willCompleteBroadcast);
|
|
317
|
+
})
|
|
318
|
+
.subscribe();
|
|
319
|
+
};
|
|
320
|
+
RXParallel.prototype.sendComplete = function (broadcast) {
|
|
321
|
+
this.willComplete = true;
|
|
322
|
+
this.willCompleteBroadcast || (this.willCompleteBroadcast = broadcast);
|
|
323
|
+
if (this.activeOperations === 0) {
|
|
324
|
+
_super.prototype.sendComplete.call(this, broadcast);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
return RXParallel;
|
|
328
|
+
}(RXOperator));
|
|
329
|
+
exports.RXParallel = RXParallel;
|
|
330
|
+
//--------------------------------------
|
|
331
|
+
// RXFilter
|
|
332
|
+
//--------------------------------------
|
|
333
|
+
var RXFilter = /** @class */ (function (_super) {
|
|
334
|
+
__extends(RXFilter, _super);
|
|
335
|
+
function RXFilter(pipe, predicate) {
|
|
336
|
+
var _this = _super.call(this, pipe) || this;
|
|
337
|
+
_this.predicate = predicate;
|
|
338
|
+
return _this;
|
|
339
|
+
}
|
|
340
|
+
RXFilter.prototype.send = function (value, broadcast) {
|
|
341
|
+
if (this.predicate(value))
|
|
342
|
+
_super.prototype.send.call(this, value, broadcast);
|
|
343
|
+
};
|
|
344
|
+
return RXFilter;
|
|
345
|
+
}(RXOperator));
|
|
346
|
+
exports.RXFilter = RXFilter;
|
|
347
|
+
//--------------------------------------
|
|
348
|
+
// RXSpread
|
|
349
|
+
//--------------------------------------
|
|
350
|
+
var RXSpread = /** @class */ (function (_super) {
|
|
351
|
+
__extends(RXSpread, _super);
|
|
352
|
+
function RXSpread() {
|
|
353
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
354
|
+
}
|
|
355
|
+
RXSpread.prototype.send = function (value, broadcast) {
|
|
356
|
+
var _this = this;
|
|
357
|
+
if (Array.isArray(value)) {
|
|
358
|
+
value.forEach(function (v) {
|
|
359
|
+
_super.prototype.send.call(_this, v, broadcast);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
else
|
|
363
|
+
_super.prototype.send.call(this, value, broadcast);
|
|
364
|
+
};
|
|
365
|
+
return RXSpread;
|
|
366
|
+
}(RXOperator));
|
|
367
|
+
exports.RXSpread = RXSpread;
|
|
368
|
+
//--------------------------------------
|
|
369
|
+
// RXSkipFirst
|
|
370
|
+
//--------------------------------------
|
|
371
|
+
//ignore value emitted just after registration of a new subscriber
|
|
372
|
+
var RXSkipFirst = /** @class */ (function (_super) {
|
|
373
|
+
__extends(RXSkipFirst, _super);
|
|
374
|
+
function RXSkipFirst() {
|
|
375
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
376
|
+
}
|
|
377
|
+
RXSkipFirst.prototype.send = function (value, broadcast) {
|
|
378
|
+
if (broadcast)
|
|
379
|
+
_super.prototype.send.call(this, value, broadcast);
|
|
380
|
+
};
|
|
381
|
+
return RXSkipFirst;
|
|
382
|
+
}(RXOperator));
|
|
383
|
+
exports.RXSkipFirst = RXSkipFirst;
|
|
384
|
+
//--------------------------------------
|
|
385
|
+
// RXSkipNullable
|
|
386
|
+
//--------------------------------------
|
|
387
|
+
var RXSkipNullable = /** @class */ (function (_super) {
|
|
388
|
+
__extends(RXSkipNullable, _super);
|
|
389
|
+
function RXSkipNullable() {
|
|
390
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
391
|
+
}
|
|
392
|
+
RXSkipNullable.prototype.send = function (value, broadcast) {
|
|
393
|
+
if (value !== null && value !== undefined)
|
|
394
|
+
_super.prototype.send.call(this, value, broadcast);
|
|
395
|
+
};
|
|
396
|
+
return RXSkipNullable;
|
|
397
|
+
}(RXOperator));
|
|
398
|
+
exports.RXSkipNullable = RXSkipNullable;
|
|
399
|
+
//--------------------------------------
|
|
400
|
+
// RXRemoveDuplicates
|
|
401
|
+
//--------------------------------------
|
|
402
|
+
var RXRemoveDuplicates = /** @class */ (function (_super) {
|
|
403
|
+
__extends(RXRemoveDuplicates, _super);
|
|
404
|
+
function RXRemoveDuplicates(pipe, value) {
|
|
405
|
+
var _this = _super.call(this, pipe) || this;
|
|
406
|
+
_this.prevValue = undefined;
|
|
407
|
+
_this.prevValue = value;
|
|
408
|
+
return _this;
|
|
409
|
+
}
|
|
410
|
+
RXRemoveDuplicates.prototype.send = function (value, broadcast) {
|
|
411
|
+
if (this.prevValue !== value) {
|
|
412
|
+
this.prevValue = value;
|
|
413
|
+
_super.prototype.send.call(this, value, broadcast);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
return RXRemoveDuplicates;
|
|
417
|
+
}(RXOperator));
|
|
418
|
+
exports.RXRemoveDuplicates = RXRemoveDuplicates;
|
|
419
|
+
var RXDebounce = /** @class */ (function (_super) {
|
|
420
|
+
__extends(RXDebounce, _super);
|
|
421
|
+
function RXDebounce(pipe, ms) {
|
|
422
|
+
var _this = _super.call(this, pipe) || this;
|
|
423
|
+
_this.buffer = Array();
|
|
424
|
+
_this.willComplete = false;
|
|
425
|
+
_this.willCompleteBroadcast = false;
|
|
426
|
+
_this.timeoutId = undefined;
|
|
427
|
+
_this.ms = ms;
|
|
428
|
+
return _this;
|
|
429
|
+
}
|
|
430
|
+
RXDebounce.prototype.startTimer = function () {
|
|
431
|
+
var _this = this;
|
|
432
|
+
if (this.timeoutId)
|
|
433
|
+
return;
|
|
434
|
+
this.timeoutId = setTimeout(function () {
|
|
435
|
+
_this.timeoutId = undefined;
|
|
436
|
+
for (var i = _this.buffer.length - 1; i >= 0; i--) {
|
|
437
|
+
var notification = _this.buffer[i];
|
|
438
|
+
if (notification.hasError) {
|
|
439
|
+
_super.prototype.sendError.call(_this, notification.error, notification.broadcast);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
_super.prototype.send.call(_this, notification.value, notification.broadcast);
|
|
443
|
+
}
|
|
444
|
+
//if (notification.broadcast) break
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
_this.buffer.length = 0;
|
|
448
|
+
if (_this.willComplete)
|
|
449
|
+
_super.prototype.sendComplete.call(_this, _this.willCompleteBroadcast);
|
|
450
|
+
}, this.ms);
|
|
451
|
+
};
|
|
452
|
+
RXDebounce.prototype.send = function (value, broadcast) {
|
|
453
|
+
this.buffer.push({ hasError: false, value: value, broadcast: broadcast });
|
|
454
|
+
this.startTimer();
|
|
455
|
+
};
|
|
456
|
+
RXDebounce.prototype.sendError = function (error, broadcast) {
|
|
457
|
+
this.buffer.push({ hasError: true, error: error, broadcast: broadcast });
|
|
458
|
+
this.startTimer();
|
|
459
|
+
};
|
|
460
|
+
RXDebounce.prototype.sendComplete = function (broadcast) {
|
|
461
|
+
this.willComplete = true;
|
|
462
|
+
this.willCompleteBroadcast || (this.willCompleteBroadcast = broadcast);
|
|
463
|
+
this.startTimer();
|
|
464
|
+
};
|
|
465
|
+
return RXDebounce;
|
|
466
|
+
}(RXOperator));
|
|
467
|
+
exports.RXDebounce = RXDebounce;
|
|
468
|
+
//--------------------------------------
|
|
469
|
+
// RXReplaceError
|
|
470
|
+
//--------------------------------------
|
|
471
|
+
var RXReplaceError = /** @class */ (function (_super) {
|
|
472
|
+
__extends(RXReplaceError, _super);
|
|
473
|
+
function RXReplaceError(pipe, replaceWith) {
|
|
474
|
+
var _this = _super.call(this, pipe) || this;
|
|
475
|
+
_this.replaceWith = replaceWith;
|
|
476
|
+
return _this;
|
|
477
|
+
}
|
|
478
|
+
RXReplaceError.prototype.sendError = function (e, broadcast) {
|
|
479
|
+
var value = this.replaceWith(e);
|
|
480
|
+
value ? this.send(value, broadcast) : _super.prototype.sendError.call(this, e, broadcast);
|
|
481
|
+
};
|
|
482
|
+
return RXReplaceError;
|
|
483
|
+
}(RXOperator));
|
|
484
|
+
exports.RXReplaceError = RXReplaceError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RXPipeline = void 0;
|
|
4
|
+
var RXOperator_js_1 = require("./RXOperator.js");
|
|
5
|
+
var RXPipeline = /** @class */ (function () {
|
|
6
|
+
function RXPipeline(dispatcher) {
|
|
7
|
+
this.type = 'pipeline';
|
|
8
|
+
this.child = new RXOperator_js_1.RXOperator(this);
|
|
9
|
+
this.dispatcher = dispatcher;
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(RXPipeline.prototype, "asOperator", {
|
|
12
|
+
get: function () { return this.child; },
|
|
13
|
+
enumerable: false,
|
|
14
|
+
configurable: true
|
|
15
|
+
});
|
|
16
|
+
RXPipeline.prototype.send = function (value, broadcast) {
|
|
17
|
+
this.child.send(value, broadcast);
|
|
18
|
+
};
|
|
19
|
+
RXPipeline.prototype.sendError = function (e, broadcast) {
|
|
20
|
+
this.child.sendError(e, broadcast);
|
|
21
|
+
};
|
|
22
|
+
RXPipeline.prototype.sendComplete = function (broadcast) {
|
|
23
|
+
this.child.sendComplete(broadcast);
|
|
24
|
+
};
|
|
25
|
+
return RXPipeline;
|
|
26
|
+
}());
|
|
27
|
+
exports.RXPipeline = RXPipeline;
|