订阅者1,2从开始就订阅了subject. 然后subject推送值1的时候, 它们都收到了.
然后订阅者2, 取消了订阅, 随后subject推送值2, 只有订阅者1收到了....后来订阅者3也订阅了subject, 然后subject推送了3, 订阅者1,3都收到了这个值....下面是一个angular 5的例子:
app.component.html:
从Subject共享Observable到多个Subscribers
Subscriber to keyup events got {{keyValue}}
app.component.ts:
import { Component } from '@angular......0,1,2,3,4,5,6,7,8
const subscribe = example.subscribe(val => console.log(val));
更好的例子是: 网速比较慢的时候,