Skip to content

Instantly share code, notes, and snippets.

@gokman
Created July 6, 2017 16:56
Show Gist options
  • Select an option

  • Save gokman/86165627c46f79e240c54e485cbb3ee2 to your computer and use it in GitHub Desktop.

Select an option

Save gokman/86165627c46f79e240c54e485cbb3ee2 to your computer and use it in GitHub Desktop.
rx subject in angular2
1 First define a Rx Subject object
private subjectObject = new Subject();
2 You can publish an event by using next() method
subjectObject.next(item);
3 when Subject object publish an event it can be listened by using subscribe
subjectObject.subscribe(value => {
console.log(value);
});
with above code you can catch the published value and can see on the console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment