Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem removing spy listener from spy handler #1459

Closed
6 tasks done
farwayer opened this issue Mar 27, 2018 · 0 comments
Closed
6 tasks done

The problem removing spy listener from spy handler #1459

farwayer opened this issue Mar 27, 2018 · 0 comments

Comments

@farwayer
Copy link
Contributor

  1. Issue:
  • Provide error messages including stacktrace
node_modules/mobx/lib/mobx.js:160
        listeners[i](event);
                    ^

TypeError: listeners[i] is not a function
    at spyReport (node_modules/mobx/lib/mobx.js:160:21)
    at spyReportStart (node_modules/mobx/lib/mobx.js:164:5)
    at notifyPropertyAddition (node_modules/mobx/lib/mobx.js:1243:9)
    at defineObservableProperty (node_modules/mobx/lib/mobx.js:1183:5)
    at Object.propertyCreator (node_modules/mobx/lib/mobx.js:1264:9)
    at initializeInstance (node_modules/mobx/lib/mobx.js:105:15)
    at Todo.set [as title] (node_modules/mobx/lib/mobx.js:92:17)
    at Object.<anonymous> (test.js:12:12)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
  • Provide a minimal sample reproduction. Create a reproduction based on this sandbox

https://codesandbox.io/s/qqz1nz9144

import { spy, decorate, observable } from 'mobx';

const stopSpy = spy(() => stopSpy());
spy(() => { });

class Todo { }
decorate(Todo, {
  title: observable,
});

const todo = new Todo();
todo.title = "";
  • Did you check this issue wasn't filed before?
  • Elaborate on your issue. What behavior did you expect?

The problem is mobx do not copy listeners before enumerate it.

https://github.com/mobxjs/mobx/blob/4.1.0/src/core/spy.ts#L11
https://github.com/mobxjs/mobx/blob/4.1.0/src/core/spy.ts#L30

  • State the versions of MobX and relevant libraries. Which browser / node / ... version?

mobx 4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant