daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Nov 21st, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable } from '@angular/core';
  2. import { Observable } from 'rxjs/Observable';
  3. import { AsyncSubject } from 'rxjs/AsyncSubject';
  4.  
  5. export interface DataValue {
  6.   items: string[];
  7. }
  8.  
  9. @Injectable()
  10. export class SharedData {
  11.   private readonly valueSubject: AsyncSubject<DataValue> =
  12.       new AsyncSubject<DataValue>();
  13.  
  14.   init(value: DataValue) {
  15.     this.valueSubject.next(value);
  16.     this.valueSubject.complete();
  17.   }
  18.  
  19.   get value(): Observable<DataValue> {
  20.     return this.valueSubject.asObservable();
  21.   }
  22. }
RAW Paste Data
Top