Skip to content

Instantly share code, notes, and snippets.

@ALEXOTANO
Last active October 10, 2019 02:25
Show Gist options
  • Save ALEXOTANO/7b0c7e6028b04b364dbfecd3ccc8137f to your computer and use it in GitHub Desktop.
Save ALEXOTANO/7b0c7e6028b04b364dbfecd3ccc8137f to your computer and use it in GitHub Desktop.
Executing next data Observable from outide the Observable, Angular TypeScript

Declare it

private obs = new Subject<string>();
public _obs = this.obs.asObservable();

it is public so you can subscribe to it from any other component

Use it any where within the class

anyMethod( ) {
   this.obs.next( data );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment