listener called after being removed

6 views
Skip to first unread message

edzis

unread,
Nov 23, 2010, 6:30:09 AM11/23/10
to as3-signals
Hey, everybody,

I keep having problems with the functionality of Signal.remove(). I am
using a signal as the central time mediator in may app and frequently
remove listeners from it inside other listeners. My problem is that
calling remove() does not remove the listener from the current list of
functions to be called. Thus a listener is being called after it is
removed. So for now I have preconditions that check if the bbb can be
executed, but that is quite annoying and creates bugs if forgotten.

What is your view on removing listeners? Why is the current
implementation as it is? Can we change this? Can you recommend me
another approach?

Edgar Simson


testSignal = new Signal();
testSignal.add(aaa);
testSignal.add(bbb);

testSignal.dispatch();
//TRACES
//call aaa
//remove aaa
//remove bbb
//call bbb

private function aaa():void {
trace("call aaa");
testSignal.remove(aaa);
trace("remove aaa");
testSignal.remove(bbb);
trace("remove bbb");
}


private function bbb():void {
trace("call bbb");
}

David Linse

unread,
Nov 23, 2010, 12:52:35 PM11/23/10
to as3-s...@googlegroups.com
i dont have a solution your "remove-issue", but just want to mention
that you could use #addOnce if you just want a single notification from the signal.

best
david
--
--------------------------------------------------
David Linse
-- freelancing web-developer --

Jessnerstr. 47
10247 Berlin

phone:    +49 (0) 30 85 71 83 97
mobile:    +49 (0) 179 79 54 469
e-mail:    david...@8ball-media.de
web:        http://8ball-media.de

___
Heute schon was Gutes getan? - www.welpennothilfe.de

Reply all
Reply to author
Forward
0 new messages