Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 1.05 KB

subject.md

File metadata and controls

39 lines (25 loc) · 1.05 KB

Subject

A special type of Observable which shares a single execution path among observers

Examples

Example 1: simple Subject

( Stackblitz )

// RxJS v6+
import { Subject } from 'rxjs';

const sub = new Subject();

sub.next(1);
sub.subscribe(console.log);
sub.next(2); // OUTPUT => 2
sub.subscribe(console.log);
sub.next(3); // OUTPUT => 3,3 (logged from both subscribers)

Related Recipes

Additional Resources


📁 Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/Subject.ts