mobxjs / mobx-angular

The MobX connector for Angular.
MIT License
483 stars 59 forks source link

console.log('detach') in NPM package #50

Closed kevindqc closed 6 years ago

kevindqc commented 6 years ago

I have angular-tree-component which has these dependencies:

+-- angular-tree-component@6.0.0 | +-- mobx@3.4.0 | `-- mobx-angular@2.0.0

When I expand a node in my tree view, I see "detach" logs from the console.

Looking where it comes from, it points me to node_modules/mobx-angular/dist/directives/mobx-autorun.directive.js.

The code inside:

MobxAutorunDirective.prototype.autoDetect = function (view) {
        if (!this.mobxAutorun || !this.mobxAutorun.dontDetach) {
            console.log('detach');
            view.detach();
        }
        var autorunName = view._view.component
            ? view._view.component.constructor.name + ".detectChanges()" // angular 4+
            : view._view.parentView.context.constructor.name + ".detectChanges()"; // angular 2
        this.dispose = autorun(autorunName, function () { return view['detectChanges'](); });
    };

There's an extra block that logs and call to view.detach that isn't in the actual code on github

Not sure where it comes from. Maybe the repository wasn't clean when it got published to NPM?

Thanks!

adamkleingit commented 6 years ago

Fixed in 2.0.1 - the build wasn't updated. Thanks for investigating