Andrea Giammarchi (2013-07-11T22:04:29.000Z)
trivial like ... 2 weak maps + a set for a single event ?

```javascript
obj.on(evt, handler);
```

.. internals ...

```javascript
// wm as private internal generic WeakMap
if (!wm.has(obj)) {
  // creates related WeakMap
  wm.set(obj, new WeakMap);
}
if (!wm.get(obj).has(evt)) {
  wm.get(obj).set(evt, new Set);
}
wm.get(obj).get(evt).add(handler);
```

I have the feeling it's very true in JS world nobody ever thinks about RAM
and GC ^_^

That said, it becomes over complicated for non concrete reason/use case if
we have strings since AFAIK WeakMap does not accept strings as key.

For all this time the event type as string has blocked like ... nobody ever
? I wonder again what's the benefit then to instantly over complicate an
API at this stage instead of looking around what worked already for
everyone.

Maybe it's me not seeing the power of objects as events.

br



On Thu, Jul 11, 2013 at 2:32 PM, Rick Waldron <waldron.rick at gmail.com>wrote:

>
>
>
> On Thu, Jul 11, 2013 at 4:45 PM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
>
>> I would simplify saying that symbols can be used as well as strings ? I
>> don't see any usefulness into using an object as event type and I think if
>> we start olready over-engineered/complicated this will never see the light
>> in any spec which is a lost/lost if you ask me
>>
>
> It's trivial if an Emitter uses something like [[MapData]] or
> [[WeakMapData]] as it's internal data property for event storage.
>
>
> Rick
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130711/ee311866/attachment-0001.html>
domenic at domenicdenicola.com (2013-07-16T14:53:07.960Z)
trivial like ... 2 weak maps + a set for a single event ?

```javascript
obj.on(evt, handler);
```

.. internals ...

```javascript
// wm as private internal generic WeakMap
if (!wm.has(obj)) {
  // creates related WeakMap
  wm.set(obj, new WeakMap);
}
if (!wm.get(obj).has(evt)) {
  wm.get(obj).set(evt, new Set);
}
wm.get(obj).get(evt).add(handler);
```

I have the feeling it's very true in JS world nobody ever thinks about RAM
and GC ^_^

That said, it becomes over complicated for non concrete reason/use case if
we have strings since AFAIK WeakMap does not accept strings as key.

For all this time the event type as string has blocked like ... nobody ever
? I wonder again what's the benefit then to instantly over complicate an
API at this stage instead of looking around what worked already for
everyone.

Maybe it's me not seeing the power of objects as events.