GithubHelp home page GithubHelp logo

Comments (1)

tangmingxiang avatar tangmingxiang commented on July 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.