ISignal.removeAll suggestion

12 views
Skip to first unread message

Zack Pierce

unread,
Jun 23, 2011, 8:12:33 PM6/23/11
to as3-signals
If you're like me and like to know precisely what's gone down after
any significant library call, you may want to consider this minor
tweak to the ISignal interface.

The ISignal.remove method returns an ISignalBinding, but the
ISignal.removeAll method currently is a void call.

How about we change it such that ISignal.removeAll returns a
collection of every ISignalBinding object removed by that call?

function removeAll():Array

This alteration improves the inspectability of the call effects, and
makes removeAll behave more closely to remove.

Returning a SignalBindingList-like specialized collection might also
be a reasonable (and type-safer) alternative to Array, but would add
more cognitive overhead.

What do you think?

Simon Richardson

unread,
Jun 24, 2011, 4:00:45 AM6/24/11
to as3-s...@googlegroups.com
Returning a ISignalBinding would be the most optimal way[1] as this should in theory be relatively free. Converting it to anything else seems like a very heavy operation if you have lots of signals and previously removeAll is extremely fast.

Also I would also be concerned about what if you tried to utilise anything on the ISignalBinding from the SignalBindingList i.e. bugs etc.

[1]
public function removeAll():SignalBindingList
{
const removed : SignalBindingList = bindings;
bindings = SignalBindingList.NIL;
return removed;

Zachary Pierce

unread,
Jun 24, 2011, 3:28:42 PM6/24/11
to as3-s...@googlegroups.com
That's an excellent point about performance, Simon.

One other issue to consider is that if we use SignalBindingList in the ISignal interface, we're pinning all as3-signals implementations to that particular class and its implementation.  Since as3-signals has done a great job of using only interfaces and core runtime classes in its interface definitions, perhaps a slightly cleaner approach would be to define an appropriate ISignalBindingList interface and update SignalBindingList to implement it.

public function removeAll():ISignalBindingList;

Simon Richardson

unread,
Jun 24, 2011, 4:29:40 PM6/24/11
to as3-s...@googlegroups.com
Have a play and see what the results are ;-)
Reply all
Reply to author
Forward
0 new messages