[Musings]
国庆第一天,参加完朋友的宝宝宴,晚上出发去潮州吃点东西,现在在pd机场写post,今天也得完成练手任务。Gogogo
今天手写Pub/Sub,其实就是解耦了昨天的EventEmitter,EventEmitter天然的热流,不带回放功能,一个列表维护on/emit,而pub/sub解耦以后可以玩的空间就更大了,能做replay回放/粘性,更可以去创建冷流
Let’s roll the first version
1 | class Subscriber { |
Output:
Now, we need to implement for the replay feature. So we need to creat a store for memorization.
1 | class SubscriberV2 { |
Output:

