Skip to content

Instantly share code, notes, and snippets.

@pglazkov
Created November 20, 2017 15:39
Show Gist options
  • Save pglazkov/ec2dd30e37108eb6fc944a8fab7e89d0 to your computer and use it in GitHub Desktop.
Save pglazkov/ec2dd30e37108eb6fc944a8fab7e89d0 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { AsyncSubject } from 'rxjs/AsyncSubject';
export interface DataValue {
items: string[];
}
@Injectable()
export class SharedData {
private readonly valueSubject: AsyncSubject<DataValue> =
new AsyncSubject<DataValue>();
init(value: DataValue) {
this.valueSubject.next(value);
this.valueSubject.complete();
}
get value(): Observable<DataValue> {
return this.valueSubject.asObservable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment