Skip to content

Instantly share code, notes, and snippets.

@workze
Created April 24, 2020 06:40
Show Gist options
  • Save workze/3674021dff3ea382afd7ae2c2683aac0 to your computer and use it in GitHub Desktop.
Save workze/3674021dff3ea382afd7ae2c2683aac0 to your computer and use it in GitHub Desktop.
设计模式 观察者模式

https://juejin.im/post/5a238da56fb9a0450a6729ff

问题:对象直接有数据依赖。如何让一个对象的数据变化,及时通知到其他对象。 解决方案:数据对象持有其他所有对象的引用,双方协商数据交换方式。当数据对象数据变化,通过接口传入数据。 通过注册产生关联;通过回调传递数据。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment