Vendorize queueing-subject

This commit is contained in:
Bálint Bokros 2018-05-18 11:31:23 +02:00
parent 4b79d77fcc
commit c357e47e93
3 changed files with 27 additions and 2 deletions

View File

@ -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",

View 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;
}
}

View File

@ -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';