christianalfoni / flux-angular

Use the FLUX architecture with Angular JS
313 stars 50 forks source link

$listenTo never updates the scope #58

Closed Phhansen closed 8 years ago

Phhansen commented 8 years ago

Hi there

I´ve been testing out flux-angular for a few days on a project.

I actually thought everything worked perfectly, until i tested it on my pc at home and nothing worked. I was wondering what cause this.

I´ve been using angular batarang ( stable ) browser extension in chrome. And if i turn this OFF, nothing updates within my $listenTo blocks in my directive.

my store holds an array like this:

days: [
    calendars: [
          0: { },
          1: { },
          ...
     ],
     ...
]

I then have a directive that goes through all days in an ng-repeat, then all calendars, also in an ng-repeat.

My problem is, that when i bind the scope variable to the store, it gets the data fine the first time.

But this code below never does anything:

            $scope.$listenTo(calendarStore, function() {
                $timeout(function() {
                    $scope.days = calendarStore.days;
                }, 0);
            });

If i put in a console.log after setting the scope variable, it does show an updated scope with the new values. BUT, nothing in the UI ever changes.

The only way it works, is when batarang is active, which i find incredibly odd. I have no idea why, as i´m pretty new with all this.

ps. this happens with both immutable stores and without.