Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 11, 2020 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/36a207a39e96cb313f24d00e7fa3868e to your computer and use it in GitHub Desktop.
Save parzibyte/36a207a39e96cb313f24d00e7fa3868e to your computer and use it in GitHub Desktop.
import {Injectable} from '@angular/core';
import {BehaviorSubject} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class DataSharingService {
private messageSource = new BehaviorSubject('default message');
currentMessage = this.messageSource.asObservable();
constructor() {
}
changeMessage(message: string) {
this.messageSource.next(message)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment