mobx-angular 2.1.1 not compatible with mobx 4.0.0 ?
KSSLR opened this issue · comments
In the mobx-autorun.directive.ts, autoDetect(view) uses mobx autorun with a wrong signature:
this.dispose = autorun(
autorunName,
() => view=> autorun(string, function)
but the mobx API expects:
autorun(fn, options?)
(https://github.com/mobxjs/mobx/blob/master/CHANGELOG.md,
https://github.com/mobxjs/mobx/blob/master/src/api/autorun.ts)
and fails at runtime:
function autorun(view, opts) {
if (opts === void 0) { opts = EMPTY_OBJECT; }
if (process.env.NODE_ENV !== "production") {
invariant(typeof view === "function", "Autorun expects a function as first argument");
invariant(isAction(view) === false, "Autorun does not accept actions since actions are untrackable");
}
as view is not of type "function"
Important!
In case you are reporting a bug, or requesting help, please reproduce it in a GIT repo or fork this online template:
https://stackblitz.com/edit/angular-usygae?file=app%2Fapp.component.html
If you are unable to reproduce, please:
- paste your package.json
- say which browser you are using
- paste your nodes and options and whatever code your feel will help reproduce the error
Thank you and happy programming
It seems not.
Look at line 39 in:
https://github.com/mobxjs/mobx-angular/blob/master/lib/directives/mobx-autorun.directive.ts
autorun needs to be migrated according to this guide:
https://github.com/mobxjs/mobx/wiki/Migrating-from-mobx-3-to-mobx-4
autorun(name, fn) -> autorun(fn, { name: name })
Fixed in 3.0.1 - can you verify?
Works on my side, thank you.