mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 05:52:56 +00:00 
			
		
		
		
	Vendorize queueing-subject
This commit is contained in:
		
							
								
								
									
										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';
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user