Unlatch

542 views
Skip to first unread message

Dan Doyon

unread,
Jan 18, 2012, 8:13:41 PM1/18/12
to ang...@googlegroups.com
Once you've created a watch on something can you unwatch?

Thx

-dan

Sent from my iPhone

Vojta Jina

unread,
Jan 19, 2012, 2:07:48 AM1/19/12
to ang...@googlegroups.com
Nope, you can only remove scope. When a scope is being destroyed, all watchers are gone as well...
But it's on my todo list, can you share your use case ?

V.

Dan Doyon

unread,
Jan 19, 2012, 2:32:13 PM1/19/12
to ang...@googlegroups.com
Vojta,

We're ok for now. We're developing an analytics system which has a chart, with a number of filtering mechanisms. Each filter (date, score, etc) has(had) its own model and $watch and what we found was IE thrashing. It really slows down when we are loading saved filters. This causes all the watchers to fire and as each watcher fires the chart was redrawing. So if you have 5 filters the chart was needlessly redrawing 5+ times (depending on how many elements in a filters model).

So what we've done in the interim is to put all the models under a root model and so there is only one $watch and this has sped things up (somewhat). Our thoughts, prior to this change, was to disable watching when we didn't need it. So, in this example, if a saved filter has been asked for, disable the watchers, load the filter (ie. update the model), redraw chart and then re-enable the watchers. 

Having an unwatch (or iphone autocorrected: unlatch ;} ) would've come in handy. $unwatch('[foo,bar,blah');

make sense?

thx

--dan 


From: Vojta Jina <vojta...@gmail.com>
To: ang...@googlegroups.com
Sent: Wednesday, January 18, 2012 11:07 PM
Subject: [angular.js] Re: Unlatch

Nope, you can only remove scope. When a scope is being destroyed, all watchers are gone as well...
But it's on my todo list, can you share your use case ?

V.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/kq8QYwj4qQQJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.


Igor Minar

unread,
Jan 19, 2012, 3:31:22 PM1/19/12
to ang...@googlegroups.com
that's not correct. $watch returns a fn which if called will deregister the listener. See:


/i

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.

Dan Doyon

unread,
Jan 19, 2012, 5:16:49 PM1/19/12
to ang...@googlegroups.com
Thanks Igor!


From: Igor Minar <ig...@angularjs.org>
To: ang...@googlegroups.com
Sent: Thursday, January 19, 2012 12:31 PM
Subject: Re: [angular.js] Re: Unlatch

Vojta Jina

unread,
Jan 20, 2012, 1:52:48 PM1/20/12
to ang...@googlegroups.com
Woow, thanks Igor, I forgot about this.

V.
Reply all
Reply to author
Forward
0 new messages