
设计模式
潇遥快乐
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
自己动手实现EventEmit
最近做React项目的时候使用了events库中的EventEmit,动手实现了一个简易版,了解到EventEmit本质上是观察者模式的一种实现。 export default class EventEmitter { constructor() { this.event = {}; this.maxListerners = 10; } // 监听 on(type,...原创 2019-10-18 15:02:36 · 2445 阅读 · 0 评论 -
js工程模式
按照某种形式批量生成对象: class Product { constructor(name) { this.name = name; } init() { alert('init'); } fun1() { alert('fun1'); } fun2() { alert('fun2'); } } class Creator { ...原创 2019-10-14 16:16:14 · 1091 阅读 · 1 评论