Skip to content

Commit

Permalink
feat($ui): Added a simple stream implementation to support dynamic UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard Kyvenko committed Jul 12, 2017
1 parent 637f579 commit eeee64a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/behavioral-subject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export class BehavioralSubject<A> {
private subscribers: Array<(value: A) => void> = [];
private _value: A;

constructor(value: A) {
this._value = value;
}

next(value: A) {
this._value = value;
this.subscribers.forEach(observer => observer(this._value));
}

subscribe(observer: (value: A) => void) {
observer(this._value);
this.subscribers.push(observer);
}
}

0 comments on commit eeee64a

Please sign in to comment.