Skip to content

Instantly share code, notes, and snippets.

@l0co
Created July 10, 2019 14:54
Show Gist options
  • Select an option

  • Save l0co/4339fb9ed08fa30f54d676660f18ee4f to your computer and use it in GitHub Desktop.

Select an option

Save l0co/4339fb9ed08fa30f54d676660f18ee4f to your computer and use it in GitHub Desktop.
RxJs BehaviorSubject used as the pipe in TypeScirpt
let subject = new BehaviorSubject<string>('0');
subject.subscribe(it => console.log('@@@@@@@@@@@@', 'A', it));
console.log('@@@@@@@@@@@@', 'emit', '1');
subject.next('1');
subject.subscribe(it => console.log('@@@@@@@@@@@@', 'B', it));
console.log('@@@@@@@@@@@@', 'emit', '2');
subject.next('2');
subject.subscribe(it => console.log('@@@@@@@@@@@@', 'C', it));
// @@@@@@@@@@@@ A 0
// @@@@@@@@@@@@ emit 1
// @@@@@@@@@@@@ A 1
// @@@@@@@@@@@@ B 1
// @@@@@@@@@@@@ emit 2
// @@@@@@@@@@@@ A 2
// @@@@@@@@@@@@ B 2
// @@@@@@@@@@@@ C 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment