📜  行为主体与主体 Angular - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:31.390000             🧑  作者: Mango

代码示例1
A BehaviorSubject holds one value. When it is subscribed it emits the value immediately.
 A Subject doesn't hold a value.

Subject example (with RxJS 5 API):

const subject = new Rx.Subject();
subject.next(1);
subject.subscribe(x => console.log(x));

BehaviorSubject example:
const subject = new Rx.Subject();
subject.next(1);
subject.subscribe(x => console.log(x));