source: trip-planner-front/node_modules/rxjs/src/internal/testing/HotObservable.ts@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import { Subject } from '../Subject';
2import { Subscriber } from '../Subscriber';
3import { Subscription } from '../Subscription';
4import { Scheduler } from '../Scheduler';
5import { TestMessage } from './TestMessage';
6import { SubscriptionLog } from './SubscriptionLog';
7import { SubscriptionLoggable } from './SubscriptionLoggable';
8import { applyMixins } from '../util/applyMixins';
9
10/**
11 * We need this JSDoc comment for affecting ESDoc.
12 * @ignore
13 * @extends {Ignored}
14 */
15export class HotObservable<T> extends Subject<T> implements SubscriptionLoggable {
16 public subscriptions: SubscriptionLog[] = [];
17 scheduler: Scheduler;
18 logSubscribedFrame: () => number;
19 logUnsubscribedFrame: (index: number) => void;
20
21 constructor(public messages: TestMessage[],
22 scheduler: Scheduler) {
23 super();
24 this.scheduler = scheduler;
25 }
26
27 /** @deprecated This is an internal implementation detail, do not use. */
28 _subscribe(subscriber: Subscriber<any>): Subscription {
29 const subject: HotObservable<T> = this;
30 const index = subject.logSubscribedFrame();
31 const subscription = new Subscription();
32 subscription.add(new Subscription(() => {
33 subject.logUnsubscribedFrame(index);
34 }));
35 subscription.add(super._subscribe(subscriber));
36 return subscription;
37 }
38
39 setup() {
40 const subject = this;
41 const messagesLength = subject.messages.length;
42 /* tslint:disable:no-var-keyword */
43 for (var i = 0; i < messagesLength; i++) {
44 (() => {
45 var message = subject.messages[i];
46 /* tslint:enable */
47 subject.scheduler.schedule(
48 () => { message.notification.observe(subject); },
49 message.frame
50 );
51 })();
52 }
53 }
54}
55applyMixins(HotObservable, [SubscriptionLoggable]);
Note: See TracBrowser for help on using the repository browser.