Skip to content

Commit aee0bd6

Browse files
author
Dustin Cleveland
committed
Replace BehaviorSubject with ReplaySubject which will prevent a default value being emitted when first subscribing to an event.
1 parent 16e2f5c commit aee0bd6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/angular2-pubsub.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable } from '@angular/core';
2-
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
2+
import { ReplaySubject } from 'rxjs/ReplaySubject';
33
import { Observable } from 'rxjs/Observable';
44
import { Subscription } from 'rxjs/Subscription';
55

@@ -21,7 +21,7 @@ export class PubSubService implements IPubSubService {
2121
}
2222

2323
if (this.events[event] === undefined) {
24-
this.events[event] = new BehaviorSubject<any>(0);
24+
this.events[event] = new ReplaySubject<any>();
2525
}
2626

2727
if (typeof callback !== 'function') {

0 commit comments

Comments
 (0)