mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 02:31:33 +00:00
Vendorize queueing-subject
This commit is contained in:
parent
4b79d77fcc
commit
c357e47e93
@ -28,7 +28,6 @@
|
||||
"core-js": "^2.4.1",
|
||||
"ng2-ace-editor": "^0.3.4",
|
||||
"node-sass": "^4.7.2",
|
||||
"queueing-subject": "^0.2.0",
|
||||
"rxjs": "^5.5.2",
|
||||
"rxjs-websockets": "^4.0.0",
|
||||
"showdown": "^1.8.5",
|
||||
|
26
src/app/services/queueing-subject.ts
Normal file
26
src/app/services/queueing-subject.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// Based on https://github.com/ohjames/queueing-subject
|
||||
|
||||
import { Subject, Subscriber, Subscription } from 'rxjs';
|
||||
|
||||
export class QueueingSubject<T> extends Subject<T> {
|
||||
private queuedValues: T[] = [];
|
||||
|
||||
next(value: T): void {
|
||||
if (this.closed || this.observers.length) {
|
||||
super.next(value);
|
||||
} else {
|
||||
this.queuedValues.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
_subscribe(subscriber: Subscriber<T>): Subscription {
|
||||
const subscription = super._subscribe(subscriber);
|
||||
|
||||
if (this.queuedValues.length) {
|
||||
this.queuedValues.forEach(value => super.next(value));
|
||||
this.queuedValues.splice(0);
|
||||
}
|
||||
|
||||
return subscription;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// All Rights Reserved. See LICENSE file for details.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { QueueingSubject } from 'queueing-subject';
|
||||
import { QueueingSubject } from './queueing-subject';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import websocketConnect from 'rxjs-websockets';
|
||||
import { filter, map, share } from 'rxjs/operators';
|
||||
|
Loading…
Reference in New Issue
Block a user