Closed johnhamm closed 7 years ago
Hey, I made some changes in 1.2.0 (specifically made mobx a peer dependency).
Can you update and see if the error repeats? Thanks
I updated ng2-mobx to 1.2.0, as well as 1.2.1, and i installed mobx 3.0.2. I get the same error as above. When I tried updating to ng-mobx 1.2.2, I get this error:
EXCEPTION: Error in ./AppComponent class AppComponent - inline template:66:13 caused by: Cannot read property 'transform' of undefined
at View_AppComponent1.createInternal (component.ngfactory.js:310)
at View_AppComponent1.AppView.create (vendor.dll.js:51784)
at View_AppComponent1.DebugAppView.create (vendor.dll.js:52040)
at TemplateRef_.createEmbeddedView (vendor.dll.js:37450)
at ViewContainerRef_.createEmbeddedView (vendor.dll.js:37574)
at new MobxAutorunDirective (eval at ./node_modules/ng2-mobx/dist/directives/mobx-autorun.directive.js (bundle.js:734), <anonymous>:20:40)
at new Wrapper_MobxAutorunDirective (wrapper.ngfactory.js:7)
at CompiledTemplate.proxyViewClass.View_AppComponent0.createInternal (component.ngfactory.js:21)
at CompiledTemplate.proxyViewClass.AppView.create (vendor.dll.js:51784)
at CompiledTemplate.proxyViewClass.DebugAppView.create (vendor.dll.js:52040)
at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.createInternal (host.ngfactory.js:16)
at CompiledTemplate.proxyViewClass.AppView.createHostView (vendor.dll.js:51791)
at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (vendor.dll.js:52051)
at ComponentFactory.create (vendor.dll.js:25638)
at ApplicationRef_.bootstrap (vendor.dll.js:24063)
In the meantime, I've converted this whole app to mobx, and was wondering if there were any other mobx mechanisms I could use to trigger code when a mobx observable changes besides "observe" which isn't currently working?
Hey, which Angular version are you using? Can you share your code?
On Tue, Jan 24, 2017 at 5:33 AM, John Hamm notifications@github.com wrote:
I updated ng2-mobx to 1.2.0, and i installed mobx 3.0.2. I now get this error:
EXCEPTION: Error in ./AppComponent class AppComponent - inline template:66:13 caused by: Cannot read property 'transform' of undefined
at View_AppComponent1.createInternal (component.ngfactory.js:310) at View_AppComponent1.AppView.create (vendor.dll.js:51784) at ViewAppComponent1.DebugAppView.create (vendor.dll.js:52040) at TemplateRef.createEmbeddedView (vendor.dll.js:37450) at ViewContainerRef_.createEmbeddedView (vendor.dll.js:37574) at new MobxAutorunDirective (eval at ./node_modules/ng2-mobx/dist/directives/mobx-autorun.directive.js (bundle.js:734),
:20:40) at new Wrapper_MobxAutorunDirective (wrapper.ngfactory.js:7) at CompiledTemplate.proxyViewClass.View_AppComponent0.createInternal (component.ngfactory.js:21) at CompiledTemplate.proxyViewClass.AppView.create (vendor.dll.js:51784) at CompiledTemplate.proxyViewClass.DebugAppView.create (vendor.dll.js:52040) at CompiledTemplate.proxyViewClass.View_AppComponentHost0.createInternal (host.ngfactory.js:16) at CompiledTemplate.proxyViewClass.AppView.createHostView (vendor.dll.js:51791) at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (vendor.dll.js:52051) at ComponentFactory.create (vendor.dll.js:25638) at ApplicationRef.bootstrap (vendor.dll.js:24063) In the meantime, I've converted this whole app to mobx, and was wondering if there were any other mobx mechanisms I could use to trigger code when a mobx observable changes besides "observe" which isn't currently working?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/500tech/ng2-mobx/issues/8#issuecomment-274692302, or mute the thread https://github.com/notifications/unsubscribe-auth/ACUsQ0kNxtx-t6OcY28KYpMcEqNlu-5-ks5rVXEYgaJpZM4LmFUy .
-- Adam Klein CTO & Co-Founder Tel. +972-52-747-5633 blog.500tech.com http://blog.500tech.com meetup.com/angularjs-il
Now I see your original error has nothing to do with ng2-mobx - you are using mobx' observe method directly. You can also use autorun
and reaction
instead of observe.
And don't forget to dispose of the observers in the ngOnDestroy
hook.
As for the error you are getting in ng2-mobx 1.2.2 - what Angular version are you using?
BTW, you can use reaction instead of observe:
this.dispose = reaction(() => this.store.currentGreeting, (greeting) => {
alert("Your greeting has changed.");
$("#myModal").modal("hide");
});
// don't forget to dispose the listener:
ngOnDestroy() {
this.dispose();
}
Hey, updated version 1.2.3 to include AoT metadata, can you recheck the error you got? Thanks
Closing this, if the problem persists please reopen. Thanks
In my ngOnInit, I am calling
observe(this.store, "currentGreeting")
to react to the greeting value changing in my store. However, I am getting this error:Here is my DomainStore:
Here is my WelcomeComponent that calls observe from ngOnInit:
I have all of my components wrapped in
<div class="jumbotron" *mobxAutorun>...</div>
and they all havechangeDetection: ChangeDetectionStrategy.OnPush
set. I'm not sure why it is not detecting that the property is decorated with @observable. Am I missing a step?