Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Stop watchers in template #14988

Closed
iamisti opened this issue Aug 5, 2016 · 1 comment
Closed

Stop watchers in template #14988

iamisti opened this issue Aug 5, 2016 · 1 comment

Comments

@iamisti
Copy link

iamisti commented Aug 5, 2016

Hi Guys,
I'd like to request a new feature if it's not yet in.
It's a performance improvement which I think should be in the framework.

The problem:
There is no way to stop watchers in a template or convert them to one-time data binding.

Use case:
I have a list of items which has some properties that can change during time. I need two-way data binding there. But there are certain changes that put them into a final state, and their data will never change anymore after that state.
At that moment the two-way data bindings are not required anymore.
And another problem with those items is the amount of them as they keep growing and the watchers are increasing continously.

Example for the feature:
aStatus:
is a status of an item which can be the following: 'new', 'pending', 'sent'

oneTimeBinding
is a filter which is supposed to stop two-way data binding and convert it to one-time data binding based on a filter which is passed as a value.

    <!-- if value of aStatus is 'sent' then stop two-way data binding -->
    <div>{{aStatus | oneTimeBinding:'sent'}}</div>

My feature request for having a 'filter' for it is just an idea, it can be anything else.
All I need is to have possibility to stop bindings in views.

Thanks in advance!

@Narretz
Copy link
Contributor

Narretz commented Aug 5, 2016

Something like this has been proposed a few times, e.g. #14798, #5301, #6354

But it's not something we are prioritizing right now.

There are some projects that do something like this: https://github.com/kasperlewau/angular-bind-notifier

If you have an actual $scope.$watch you can also use the returned unwatch function to stop watching.

@Narretz Narretz closed this as completed Aug 5, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants