Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isState filter needs to be marked as stateful (introduced in AngularJS 1.3.0-rc.2, affects all newer versions as well) #1479

Closed
dbkang opened this issue Oct 23, 2014 · 6 comments
Assignees
Labels
Milestone

Comments

@dbkang
Copy link
Contributor

dbkang commented Oct 23, 2014

Due to this change in AngularJS,

angular/angular.js@fca6be7

Which assumes that filters are stateless or purely functional unless specifically marked as stateful, watch expressions that use isState filter, which is of course stateful, do not update unless input values change, even if the state has changed.

I assume the same applies to includedByState filter as well, though I have not used it.

@dbkang dbkang changed the title isState filter needs to be marked as stateful (AngularJS 1.3.0-rc.2) isState filter needs to be marked as stateful (introduced in AngularJS 1.3.0-rc.2, affects all newer versions as well) Oct 23, 2014
@christopherthielen
Copy link
Contributor

Thanks.

We've discussed deprecating and removing these filters. Do you use them? Would you be terribly offended if we made you implement them in your own codebase?

@christopherthielen christopherthielen added this to the 0.2.12 milestone Oct 23, 2014
@christopherthielen christopherthielen self-assigned this Oct 23, 2014
@dbkang
Copy link
Contributor Author

dbkang commented Oct 23, 2014

I do use isState but no I wouldn't be offended by its removal. I use it because I'd rather use existing functionality but at one point I'd already written this wrapper (and attached it to the scope) before being aware of its existence. Exposing this functionality as a filter is somewhat odd and only necessitated by there being no way to inject services into the markup.

@nateabele
Copy link
Contributor

@christopherthielen Yeah, the more I think about it, the more I feel like filters are just not the right fit for what we're doing with them. I reiterate my +1 for deprecation, and upgrade it to suggesting that we just remove them outright. I don't know that there's a way we can fix this barring seriously core surgery.

@christopherthielen
Copy link
Contributor

"fix" would be marking them as stateful, which I think we should do for 0.2.x then remove them in 1.0

myApp.filter('myFilter', function() {
  function myFilter(input) { ... };
  myFilter.$stateful = true;
  return myFilter;
});

@nateabele
Copy link
Contributor

Ah, okay. Didn't realize that was an option. Good plan.

@adharris
Copy link
Contributor

For anyone who is encountering this, you can workaround by setting $stateful in a decorator:

app.config(['$provide', function($provide) {

    var makeStateful = ["$delegate", function($delegate) {
        $delegate.$stateful = true;
        return $delegate;
    }];

    $provide.decorator('includedByStateFilter', makeStateful);
    $provide.decorator('isStateFilter', makeStateful);
}]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants