Comments (1)
class SimpleObservable 中的代码可能有一点 bug,我先 注册(subscribe) 一系列函数,如果我之后把这一系列函数中先注册的函数,先注销(unscribble) 掉的话,那么后注册的函数就无法再注销掉了,因为 observer 数组的长度在注销的时候会发生变化,可以这样修改一下:
1. subscribe() 中将 that.observer.splice(this._index, 1); 改为 that.observer.splice(this._index, 1, null);
2. next(_data) 中 this.observer[i](_data); 改为 this.observer[i] && this.observer[i](_data);
from exercise17.
Related Issues (2)
- test.js 断言小概率错误 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exercise17.