Hi to you all metoer-fans!
TL;DR
Are this.autorun
functions supported on Angular 1.6.1 components? They are unreliable in my app
Details:
I hook this.autorun
functions on angular component controllers. Although initially responsive, the autoruns tend to not trigger from some point.
By ‘component’ I mean:
angular.module(‘myModule’).component(‘myComponent’, {
When controllers start, autoruns seem to trigger as expected. Then at some point, in response to a change in a Session variable, they seem to no longer trigger. This has affected various components in my project. I’ve verified it using a simple test: Added a this.autorun(..)
function which console.log’s a Session variable. When I suspect that controller autoruns should have fired but didn’t, I change that Session variable using Session.set('testKey', 'new value')
at the console. The expected log no longer appears => the autorun didn’t run.
I’ve also verified the controller is still loaded by logging at the controller’s $scope.$on($destroy)
(it wasn’t called, thus I’m inclined to believe that there’s no bug in my code which removed the component).
My question is:
Is using this.autorun
supported in angular components?
Note: this question was also posted on stackoverflow