flinker 1.0.0 → 1.0.6

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.
@@ -0,0 +1,733 @@
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.RXQueue = exports.RXQueueOperator = exports.RXObservableValue = exports.RXObservableEntity = exports.RXWaitUntilComplete = exports.RXFrom = exports.RXCombine = exports.RXOperation = exports.RXBuffer = exports.RXSubject = exports.RXEmitter = exports.RXDelayedError = exports.RXDelayedComplete = exports.RXJustError = exports.RXJustComplete = exports.RXPublisher = void 0;
19
+ var RXPipeline_1 = require("./RXPipeline");
20
+ //WeakRef is not supported in RN
21
+ // export class RXPipelineGarbage {
22
+ // static self = new RXPipelineGarbage()
23
+ // private readonly list = Array<WeakRef<RXAnyPipeline>>()
24
+ // private total = 0
25
+ //
26
+ // register(p: RXAnyPipeline) {
27
+ // this.list.push(new WeakRef(p))
28
+ // this.total++
29
+ // this.log()
30
+ // }
31
+ //
32
+ // log() {
33
+ // const disposedCount = this.list.reduce((res, ref) => ref.deref() ? res + 1 : res, 0)
34
+ // Logger.i('GC: disposed pipelines:', disposedCount + '/' + this.total)
35
+ // }
36
+ // }
37
+ var generateSUID = (function () {
38
+ var value = 0;
39
+ return function () {
40
+ return value++;
41
+ };
42
+ })();
43
+ var RXPublisher = /** @class */ (function () {
44
+ function RXPublisher() {
45
+ this.suid = generateSUID();
46
+ this.type = 'observable';
47
+ this._isComplete = false;
48
+ this.pendingUnsubscribePipes = Array();
49
+ //--------------------------------------
50
+ // Sending methods
51
+ //--------------------------------------
52
+ this.isSending = false;
53
+ this.pipelines = Array();
54
+ }
55
+ Object.defineProperty(RXPublisher.prototype, "volume", {
56
+ get: function () { return this.pipelines.length; },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ Object.defineProperty(RXPublisher.prototype, "asObservable", {
61
+ get: function () { return this; },
62
+ enumerable: false,
63
+ configurable: true
64
+ });
65
+ Object.defineProperty(RXPublisher.prototype, "isComplete", {
66
+ get: function () { return this._isComplete; },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ RXPublisher.prototype.pipe = function () {
71
+ var pipe = new RXPipeline_1.RXPipeline(this);
72
+ this.pipelines.push(pipe);
73
+ //RXPipelineGarbage.self.register(pipe)
74
+ return pipe.asOperator;
75
+ };
76
+ RXPublisher.prototype.didSubscribe = function (p) {
77
+ this.isComplete && p.sendComplete(false);
78
+ };
79
+ RXPublisher.prototype.didUnsubscribe = function (p) {
80
+ if (this.isSending) {
81
+ this.pendingUnsubscribePipes.push(p);
82
+ return;
83
+ }
84
+ var index = this.pipelines.indexOf(p);
85
+ index !== -1 && this.pipelines.splice(index, 1);
86
+ };
87
+ RXPublisher.prototype.send = function (value) {
88
+ this.isSending = true;
89
+ this.pipelines.forEach(function (i) { i.send(value, true); });
90
+ this.isSending = false;
91
+ this.runPendingOperations();
92
+ };
93
+ RXPublisher.prototype.sendError = function (e) {
94
+ this.isSending = true;
95
+ this.pipelines.forEach(function (i) { i.sendError(e, true); });
96
+ this.isSending = false;
97
+ this.runPendingOperations();
98
+ };
99
+ RXPublisher.prototype.sendComplete = function () {
100
+ this.isSending = true;
101
+ this._isComplete = true;
102
+ this.pipelines.forEach(function (i) { i.sendComplete(true); });
103
+ this.pipelines.length = 0;
104
+ this.isSending = false;
105
+ this.runPendingOperations();
106
+ };
107
+ RXPublisher.prototype.runPendingOperations = function () {
108
+ var _this = this;
109
+ if (this.isSending)
110
+ return;
111
+ if (this.pendingUnsubscribePipes.length > 0) {
112
+ this.pendingUnsubscribePipes.forEach(function (p) { _this.didUnsubscribe(p); });
113
+ this.pendingUnsubscribePipes.length = 0;
114
+ }
115
+ };
116
+ return RXPublisher;
117
+ }());
118
+ exports.RXPublisher = RXPublisher;
119
+ //--------------------------------------
120
+ // RXJustComplete
121
+ //--------------------------------------
122
+ var RXJustComplete = /** @class */ (function (_super) {
123
+ __extends(RXJustComplete, _super);
124
+ function RXJustComplete(value) {
125
+ var _this = _super.call(this) || this;
126
+ _this.value = value;
127
+ value !== undefined && _this.send(value);
128
+ _this.sendComplete();
129
+ return _this;
130
+ }
131
+ RXJustComplete.prototype.didSubscribe = function (p) {
132
+ this.isComplete && this.value !== undefined && p.send(this.value, false);
133
+ this.isComplete && p.sendComplete(false);
134
+ };
135
+ return RXJustComplete;
136
+ }(RXPublisher));
137
+ exports.RXJustComplete = RXJustComplete;
138
+ //--------------------------------------
139
+ // RXJustError
140
+ //--------------------------------------
141
+ var RXJustError = /** @class */ (function (_super) {
142
+ __extends(RXJustError, _super);
143
+ function RXJustError(error) {
144
+ var _this = _super.call(this) || this;
145
+ _this.error = error;
146
+ _this.sendError(error);
147
+ _this.sendComplete();
148
+ return _this;
149
+ }
150
+ RXJustError.prototype.didSubscribe = function (p) {
151
+ this.isComplete && p.sendError(this.error, false);
152
+ this.isComplete && p.sendComplete(false);
153
+ };
154
+ return RXJustError;
155
+ }(RXPublisher));
156
+ exports.RXJustError = RXJustError;
157
+ //--------------------------------------
158
+ // RXDelayedComplete
159
+ //--------------------------------------
160
+ var RXDelayedComplete = /** @class */ (function (_super) {
161
+ __extends(RXDelayedComplete, _super);
162
+ function RXDelayedComplete(ms, value) {
163
+ var _this = _super.call(this) || this;
164
+ _this.value = value;
165
+ setTimeout(function () {
166
+ value !== undefined && _this.send(value);
167
+ _this.sendComplete();
168
+ }, ms);
169
+ return _this;
170
+ }
171
+ RXDelayedComplete.prototype.didSubscribe = function (p) {
172
+ this.isComplete && this.value !== undefined && p.send(this.value, false);
173
+ this.isComplete && p.sendComplete(false);
174
+ };
175
+ return RXDelayedComplete;
176
+ }(RXPublisher));
177
+ exports.RXDelayedComplete = RXDelayedComplete;
178
+ //--------------------------------------
179
+ // RXDelayedError
180
+ //--------------------------------------
181
+ var RXDelayedError = /** @class */ (function (_super) {
182
+ __extends(RXDelayedError, _super);
183
+ function RXDelayedError(ms, error) {
184
+ var _this = _super.call(this) || this;
185
+ _this.error = error;
186
+ setTimeout(function () {
187
+ _this.sendError(error);
188
+ _this.sendComplete();
189
+ }, ms);
190
+ return _this;
191
+ }
192
+ RXDelayedError.prototype.didSubscribe = function (p) {
193
+ this.isComplete && p.sendError(this.error, false);
194
+ this.isComplete && p.sendComplete(false);
195
+ };
196
+ return RXDelayedError;
197
+ }(RXPublisher));
198
+ exports.RXDelayedError = RXDelayedError;
199
+ //--------------------------------------
200
+ // RXEmitter
201
+ //--------------------------------------
202
+ var RXEmitter = /** @class */ (function (_super) {
203
+ __extends(RXEmitter, _super);
204
+ function RXEmitter() {
205
+ var _this = this;
206
+ console.log('new RXEmitter');
207
+ _this = _super.call(this) || this;
208
+ _this._hasValue = false;
209
+ _this.hasError = false;
210
+ _this._err = undefined;
211
+ return _this;
212
+ }
213
+ Object.defineProperty(RXEmitter.prototype, "value", {
214
+ get: function () { return this._value; },
215
+ enumerable: false,
216
+ configurable: true
217
+ });
218
+ Object.defineProperty(RXEmitter.prototype, "err", {
219
+ get: function () { return this._err; },
220
+ enumerable: false,
221
+ configurable: true
222
+ });
223
+ RXEmitter.prototype.send = function (value) {
224
+ if (this.isComplete)
225
+ return;
226
+ this._value = value;
227
+ this._hasValue = true;
228
+ _super.prototype.send.call(this, value);
229
+ };
230
+ RXEmitter.prototype.sendError = function (e) {
231
+ if (this.isComplete)
232
+ return;
233
+ this._err = e;
234
+ this.hasError = true;
235
+ _super.prototype.sendError.call(this, e);
236
+ };
237
+ RXEmitter.prototype.sendComplete = function () {
238
+ if (this.isComplete)
239
+ return;
240
+ _super.prototype.sendComplete.call(this);
241
+ };
242
+ RXEmitter.prototype.didSubscribe = function (p) {
243
+ this.hasError && p.sendError(this.err, false);
244
+ !this.hasError && this._hasValue && p.send(this.value, false);
245
+ this.isComplete && p.sendComplete(false);
246
+ };
247
+ return RXEmitter;
248
+ }(RXPublisher));
249
+ exports.RXEmitter = RXEmitter;
250
+ //--------------------------------------
251
+ // RXSubject
252
+ //--------------------------------------
253
+ var RXSubject = /** @class */ (function (_super) {
254
+ __extends(RXSubject, _super);
255
+ function RXSubject(value) {
256
+ var _this = _super.call(this) || this;
257
+ _this._hasError = false;
258
+ _this._err = undefined;
259
+ _this._value = value;
260
+ return _this;
261
+ }
262
+ Object.defineProperty(RXSubject.prototype, "value", {
263
+ get: function () { return this._value; },
264
+ enumerable: false,
265
+ configurable: true
266
+ });
267
+ Object.defineProperty(RXSubject.prototype, "err", {
268
+ get: function () {
269
+ return this._err;
270
+ },
271
+ enumerable: false,
272
+ configurable: true
273
+ });
274
+ RXSubject.prototype.send = function (value) {
275
+ if (this.isComplete)
276
+ return;
277
+ this._value = value;
278
+ _super.prototype.send.call(this, value);
279
+ };
280
+ RXSubject.prototype.resend = function () {
281
+ _super.prototype.send.call(this, this.value);
282
+ };
283
+ RXSubject.prototype.sendError = function (e) {
284
+ if (this.isComplete)
285
+ return;
286
+ this._err = e;
287
+ this._hasError = true;
288
+ _super.prototype.sendError.call(this, e);
289
+ };
290
+ RXSubject.prototype.sendComplete = function () {
291
+ if (this.isComplete)
292
+ return;
293
+ this._isComplete = true;
294
+ _super.prototype.sendComplete.call(this);
295
+ };
296
+ RXSubject.prototype.didSubscribe = function (p) {
297
+ this._hasError && p.sendError(this.err, false);
298
+ !this._hasError && p.send(this.value, false);
299
+ this.isComplete && p.sendComplete(false);
300
+ };
301
+ return RXSubject;
302
+ }(RXPublisher));
303
+ exports.RXSubject = RXSubject;
304
+ //--------------------------------------
305
+ // RXBuffer
306
+ //--------------------------------------
307
+ var RXBuffer = /** @class */ (function (_super) {
308
+ __extends(RXBuffer, _super);
309
+ function RXBuffer() {
310
+ var _this = _super !== null && _super.apply(this, arguments) || this;
311
+ _this.values = Array();
312
+ _this.errors = Array();
313
+ _this.isError = Array();
314
+ return _this;
315
+ }
316
+ RXBuffer.prototype.send = function (value) {
317
+ if (this.isComplete)
318
+ return;
319
+ this.values.push(value);
320
+ this.isError.push(false);
321
+ _super.prototype.send.call(this, value);
322
+ };
323
+ RXBuffer.prototype.sendError = function (e) {
324
+ if (this.isComplete)
325
+ return;
326
+ this.errors.push(e);
327
+ this.isError.push(true);
328
+ _super.prototype.sendError.call(this, e);
329
+ };
330
+ RXBuffer.prototype.sendComplete = function () {
331
+ if (this.isComplete)
332
+ return;
333
+ this._isComplete = true;
334
+ _super.prototype.sendComplete.call(this);
335
+ };
336
+ RXBuffer.prototype.didSubscribe = function (p) {
337
+ for (var i = 0, v = 0, e = 0; i < this.isError.length; i++) {
338
+ if (this.isError[i]) {
339
+ e < this.errors.length && p.sendError(this.errors[e], false);
340
+ e++;
341
+ }
342
+ else {
343
+ v < this.values.length && p.send(this.values[v], false);
344
+ v++;
345
+ }
346
+ }
347
+ this.isComplete && p.sendComplete(false);
348
+ };
349
+ return RXBuffer;
350
+ }(RXPublisher));
351
+ exports.RXBuffer = RXBuffer;
352
+ //--------------------------------------
353
+ // RXOperation
354
+ //--------------------------------------
355
+ var RXOperation = /** @class */ (function (_super) {
356
+ __extends(RXOperation, _super);
357
+ function RXOperation() {
358
+ var _this = _super !== null && _super.apply(this, arguments) || this;
359
+ _this._value = undefined;
360
+ _this._hasError = false;
361
+ _this._err = undefined;
362
+ return _this;
363
+ }
364
+ Object.defineProperty(RXOperation.prototype, "value", {
365
+ get: function () { return this._value; },
366
+ enumerable: false,
367
+ configurable: true
368
+ });
369
+ Object.defineProperty(RXOperation.prototype, "err", {
370
+ get: function () { return this._err; },
371
+ enumerable: false,
372
+ configurable: true
373
+ });
374
+ RXOperation.prototype.success = function (value) {
375
+ if (this.isComplete)
376
+ return;
377
+ this._value = value;
378
+ _super.prototype.send.call(this, value);
379
+ _super.prototype.sendComplete.call(this);
380
+ };
381
+ RXOperation.prototype.fail = function (e) {
382
+ if (this.isComplete)
383
+ return;
384
+ this._err = e;
385
+ this._hasError = true;
386
+ _super.prototype.sendError.call(this, e);
387
+ _super.prototype.sendComplete.call(this);
388
+ };
389
+ RXOperation.prototype.didSubscribe = function (p) {
390
+ if (!this.isComplete)
391
+ return;
392
+ if (this._hasError) {
393
+ p.sendError(this.err, false);
394
+ p.sendComplete(false);
395
+ }
396
+ else {
397
+ p.send(this.value, false);
398
+ p.sendComplete(false);
399
+ }
400
+ };
401
+ return RXOperation;
402
+ }(RXPublisher));
403
+ exports.RXOperation = RXOperation;
404
+ //--------------------------------------
405
+ // RXCombine
406
+ //--------------------------------------
407
+ var RXCombine = /** @class */ (function (_super) {
408
+ __extends(RXCombine, _super);
409
+ function RXCombine(list) {
410
+ var _this = this;
411
+ console.log('new RXCombine');
412
+ _this = _super.call(this) || this;
413
+ _this._values = [];
414
+ _this._hasError = false;
415
+ _this._err = undefined;
416
+ var count = list.length;
417
+ _this._values = new Array(list.length).fill(undefined);
418
+ list.forEach(function (rx, ind) {
419
+ var op = rx instanceof RXPublisher ? rx.asObservable.pipe() : rx;
420
+ op.onReceive(function (v) {
421
+ _this.values[ind] = v;
422
+ _super.prototype.send.call(_this, _this.values);
423
+ })
424
+ .onError(function (e) {
425
+ _this._err = e;
426
+ _this._hasError = true;
427
+ _super.prototype.sendError.call(_this, e);
428
+ })
429
+ .onComplete(function () {
430
+ count--;
431
+ if (count === 0) {
432
+ _this._isComplete = true;
433
+ _super.prototype.sendComplete.call(_this);
434
+ }
435
+ })
436
+ .subscribe();
437
+ });
438
+ if (count === 0) {
439
+ _super.prototype.sendComplete.call(_this);
440
+ }
441
+ return _this;
442
+ }
443
+ Object.defineProperty(RXCombine.prototype, "values", {
444
+ get: function () { return this._values; },
445
+ enumerable: false,
446
+ configurable: true
447
+ });
448
+ Object.defineProperty(RXCombine.prototype, "err", {
449
+ get: function () { return this._err; },
450
+ enumerable: false,
451
+ configurable: true
452
+ });
453
+ RXCombine.prototype.didSubscribe = function (p) {
454
+ !this._hasError && p.send(this.values, false);
455
+ this._hasError && p.sendError(this.err, false);
456
+ this.isComplete && p.sendComplete(false);
457
+ };
458
+ return RXCombine;
459
+ }(RXPublisher));
460
+ exports.RXCombine = RXCombine;
461
+ //--------------------------------------
462
+ // RXFrom
463
+ //--------------------------------------
464
+ var RXFrom = /** @class */ (function (_super) {
465
+ __extends(RXFrom, _super);
466
+ function RXFrom(list) {
467
+ var _this = this;
468
+ console.log('new RXFrom');
469
+ _this = _super.call(this) || this;
470
+ _this.values = list;
471
+ _this.sendComplete();
472
+ return _this;
473
+ }
474
+ RXFrom.prototype.didSubscribe = function (p) {
475
+ this.values.forEach(function (v) { p.send(v, false); });
476
+ p.sendComplete(false);
477
+ };
478
+ return RXFrom;
479
+ }(RXPublisher));
480
+ exports.RXFrom = RXFrom;
481
+ //--------------------------------------
482
+ // RXWaitUntilComplete
483
+ //--------------------------------------
484
+ /*
485
+ * wait until all publishers are complete and then send a value of the last publisher if it's specified
486
+ * */
487
+ var RXWaitUntilComplete = /** @class */ (function (_super) {
488
+ __extends(RXWaitUntilComplete, _super);
489
+ function RXWaitUntilComplete(list, resultPublisher) {
490
+ var _this = this;
491
+ console.log('new RXSequence');
492
+ _this = _super.call(this) || this;
493
+ _this._value = undefined;
494
+ _this._hasError = false;
495
+ _this._err = undefined;
496
+ _this._resultPublisher = resultPublisher;
497
+ var count = Array.isArray(list) ? list.length : 1;
498
+ if (Array.isArray(list)) {
499
+ list.forEach(function (ob) {
500
+ return ob.pipe()
501
+ .onError(function (e) {
502
+ _this._err = e;
503
+ _this._hasError = true;
504
+ _super.prototype.sendError.call(_this, e);
505
+ })
506
+ .onComplete(function () {
507
+ count--;
508
+ if (count === 0)
509
+ _this.subscribeToResultPublisher();
510
+ })
511
+ .subscribe();
512
+ });
513
+ if (count === 0)
514
+ _this.subscribeToResultPublisher();
515
+ }
516
+ else {
517
+ list.pipe()
518
+ .onError(function (e) {
519
+ _this._err = e;
520
+ _this._hasError = true;
521
+ _super.prototype.sendError.call(_this, e);
522
+ })
523
+ .onComplete(function () {
524
+ _this.subscribeToResultPublisher();
525
+ })
526
+ .subscribe();
527
+ }
528
+ return _this;
529
+ }
530
+ Object.defineProperty(RXWaitUntilComplete.prototype, "value", {
531
+ get: function () { return this._value; },
532
+ enumerable: false,
533
+ configurable: true
534
+ });
535
+ Object.defineProperty(RXWaitUntilComplete.prototype, "err", {
536
+ get: function () { return this._err; },
537
+ enumerable: false,
538
+ configurable: true
539
+ });
540
+ RXWaitUntilComplete.prototype.subscribeToResultPublisher = function () {
541
+ var _this = this;
542
+ if (this._resultPublisher) {
543
+ this._resultPublisher.pipe()
544
+ .onReceive(function (v) {
545
+ _this._value = v;
546
+ _super.prototype.send.call(_this, v);
547
+ })
548
+ .onError(function (e) {
549
+ _this._err = e;
550
+ _this._hasError = true;
551
+ _super.prototype.sendError.call(_this, e);
552
+ })
553
+ .onComplete(function () {
554
+ _this._isComplete = true;
555
+ _super.prototype.sendComplete.call(_this);
556
+ })
557
+ .subscribe();
558
+ }
559
+ else {
560
+ this._isComplete = true;
561
+ _super.prototype.sendComplete.call(this);
562
+ }
563
+ };
564
+ RXWaitUntilComplete.prototype.didSubscribe = function (p) {
565
+ var _a;
566
+ !this._hasError && this.isComplete && ((_a = this._resultPublisher) === null || _a === void 0 ? void 0 : _a.isComplete) && p.send(this.value, false);
567
+ this._hasError && p.sendError(this.err, false);
568
+ this.isComplete && p.sendComplete(false);
569
+ };
570
+ return RXWaitUntilComplete;
571
+ }(RXPublisher));
572
+ exports.RXWaitUntilComplete = RXWaitUntilComplete;
573
+ /*
574
+ *
575
+ * UI
576
+ *
577
+ * */
578
+ //--------------------------------------
579
+ // RXObservableEntity
580
+ //--------------------------------------
581
+ var RXObservableEntity = /** @class */ (function (_super) {
582
+ __extends(RXObservableEntity, _super);
583
+ function RXObservableEntity() {
584
+ return _super !== null && _super.apply(this, arguments) || this;
585
+ }
586
+ RXObservableEntity.prototype.mutated = function () {
587
+ this.send(this);
588
+ };
589
+ RXObservableEntity.prototype.send = function (value) {
590
+ _super.prototype.send.call(this, value);
591
+ };
592
+ RXObservableEntity.prototype.dispose = function () {
593
+ this.sendComplete();
594
+ };
595
+ RXObservableEntity.prototype.didSubscribe = function (p) {
596
+ p.send(this, false);
597
+ this.isComplete && p.sendComplete(false);
598
+ };
599
+ return RXObservableEntity;
600
+ }(RXPublisher));
601
+ exports.RXObservableEntity = RXObservableEntity;
602
+ //--------------------------------------
603
+ // RXMutableValue
604
+ //--------------------------------------
605
+ var RXObservableValue = /** @class */ (function (_super) {
606
+ __extends(RXObservableValue, _super);
607
+ function RXObservableValue(value) {
608
+ var _this = _super.call(this) || this;
609
+ _this._value = value;
610
+ return _this;
611
+ }
612
+ Object.defineProperty(RXObservableValue.prototype, "value", {
613
+ get: function () { return this._value; },
614
+ set: function (value) {
615
+ if (value !== this._value) {
616
+ this._value = value;
617
+ _super.prototype.send.call(this, value);
618
+ }
619
+ },
620
+ enumerable: false,
621
+ configurable: true
622
+ });
623
+ RXObservableValue.prototype.didSubscribe = function (p) {
624
+ p.send(this.value, false);
625
+ this.isComplete && p.sendComplete(false);
626
+ };
627
+ return RXObservableValue;
628
+ }(RXPublisher));
629
+ exports.RXObservableValue = RXObservableValue;
630
+ var RXQueueOperator = /** @class */ (function () {
631
+ function RXQueueOperator(op) {
632
+ this.inProgress = true;
633
+ this.value = undefined;
634
+ this.op = op;
635
+ }
636
+ //--------------------------------------
637
+ // RXSender Protocol
638
+ //--------------------------------------
639
+ RXQueueOperator.prototype.send = function (value) {
640
+ var _a;
641
+ if (!this.op.isComplete) {
642
+ (_a = this.child) === null || _a === void 0 ? void 0 : _a.send(value);
643
+ }
644
+ };
645
+ //--------------------------------------
646
+ // OPERATORS
647
+ //--------------------------------------
648
+ RXQueueOperator.prototype.next = function (f) {
649
+ var operator = this.addChild(new RXQueueNext(this.op, f));
650
+ if (!this.inProgress) {
651
+ operator.send(this.value);
652
+ }
653
+ return operator;
654
+ };
655
+ RXQueueOperator.prototype.addChild = function (op) {
656
+ this.child = op;
657
+ return op;
658
+ };
659
+ RXQueueOperator.prototype.complete = function () {
660
+ var _this = this;
661
+ if (!this.op.isComplete) {
662
+ this.next(function (res) {
663
+ _this.op.success(res);
664
+ return _this.op;
665
+ });
666
+ }
667
+ return this.op.asObservable;
668
+ };
669
+ return RXQueueOperator;
670
+ }());
671
+ exports.RXQueueOperator = RXQueueOperator;
672
+ var RXQueueNext = /** @class */ (function (_super) {
673
+ __extends(RXQueueNext, _super);
674
+ function RXQueueNext(op, mapper) {
675
+ var _this = _super.call(this, op) || this;
676
+ _this.mapper = mapper;
677
+ return _this;
678
+ }
679
+ RXQueueNext.prototype.send = function (value) {
680
+ var _this = this;
681
+ if (this.op.isComplete)
682
+ return;
683
+ var rx = this.mapper(value);
684
+ rx.pipe()
685
+ .onReceive(function (v) {
686
+ _this.value = v;
687
+ })
688
+ .onError(function (e) {
689
+ _this.op.fail(e);
690
+ })
691
+ .onComplete(function () {
692
+ _this.inProgress = false;
693
+ _super.prototype.send.call(_this, _this.value);
694
+ })
695
+ .subscribe();
696
+ };
697
+ return RXQueueNext;
698
+ }(RXQueueOperator));
699
+ var RXQueue = /** @class */ (function (_super) {
700
+ __extends(RXQueue, _super);
701
+ function RXQueue() {
702
+ var _this = _super.call(this, new RXOperation()) || this;
703
+ _this.inProgress = false;
704
+ return _this;
705
+ }
706
+ Object.defineProperty(RXQueue.prototype, "asObservable", {
707
+ //--------------------------------------
708
+ // asObservable
709
+ //--------------------------------------
710
+ get: function () { return this.op.asObservable; },
711
+ enumerable: false,
712
+ configurable: true
713
+ });
714
+ Object.defineProperty(RXQueue.prototype, "isComplete", {
715
+ //--------------------------------------
716
+ // isComplete
717
+ //--------------------------------------
718
+ get: function () { return this.op.isComplete; },
719
+ enumerable: false,
720
+ configurable: true
721
+ });
722
+ RXQueue.prototype.next = function (f) {
723
+ return _super.prototype.next.call(this, f);
724
+ };
725
+ RXQueue.prototype.success = function (v) {
726
+ this.op.success(v);
727
+ };
728
+ RXQueue.prototype.fail = function (e) {
729
+ this.op.fail(e);
730
+ };
731
+ return RXQueue;
732
+ }(RXQueueOperator));
733
+ exports.RXQueue = RXQueue;