# Documenting dispatched events

**URL:** <https://es.discourse.group/t/documenting-dispatched-events/2043>\
**Category:** I have questions\
**Created:** [May 24, 2024, 9:54pm UTC](https://es.discourse.group/t/documenting-dispatched-events/2043 "2024-05-24T21:54:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheusds](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/matheusds/32/2093_2.png) [@matheusds](https://es.discourse.group/u/matheusds)\
**Post date:** [May 24, 2024, 9:54pm UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/1 "2024-05-24T21:54:00Z")

</div>

I've recently deepened in Apache Flex a bit and found out they handle events in a particular way.

The `[Event]` meta-data in AS3 isn't just for documenting dispatched events at the ASDoc level, but also for allowing MXML components to handle events. (MXML is specific to the Flex technology which evaluated in Flash or AIR.)

Are there any plans on allowing ECMAScript to use arbitrary, character meta-data as in ECMAScript 4?

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [May 24, 2024, 10:41pm UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/2 "2024-05-24T22:41:06Z")

</div>

The language doesn’t have events. Can you elaborate on what you’re asking?

---

<div class="post-metadata">

**Author:** ![matheusds](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/matheusds/32/2093_2.png) [@matheusds](https://es.discourse.group/u/matheusds)\
**Post date:** [May 25, 2024, 12:26am UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/3 "2024-05-25T00:26:47Z")

</div>

I was considering that the JSDoc tool supports `@event` tags used to document dispatched events in usual event cycles such as DOM events and Display List events.

I thought it'd be allowed to discuss these here, even though this is a ECMAScript community.

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [May 25, 2024, 7:31am UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/4 "2024-05-25T07:31:02Z")

</div>

> [@matheusds](#):
>
> Are there any plans on allowing ECMAScript to use arbitrary, character meta-data as in ECMAScript 4?

Could you show an example? I'm not sure what "character meta-data" refers to. Thanks!

---

<div class="post-metadata">

**Author:** ![matheusds](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/matheusds/32/2093_2.png) [@matheusds](https://es.discourse.group/u/matheusds)\
**Post date:** [May 25, 2024, 10:00am UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/5 "2024-05-25T10:00:35Z")

</div>

Right

> [@aclaymore](#):
>
> character meta-data

In ActionScript 3, meta data attached to annotatable directives such as class definitions or variable definitions are simply repeatable (not unique), key-value entries, where the key is optional and is an `Identifier`, and the value is a String literal or, if the entry is keyless, the value may appear solely as an `Identifier` translating to a String.

ES4 examples:

```javascript
[M1]
[M1(x = "y", y = "z")]
[M1("y")]
[M1(y)]
var x

```

There is no static typing involved in meta-data; the ES4 compilers each may have different behavior when processing them.

In the case of documenting events, the `[Event]` meta-data in Apache Flex looks as follows, considering an `EventDispatcher`:

```as3
package com.example.demo {
    import flash.events.*;

    /**
     * @eventType DoorEvent.ENTER
     */
    [Event(name = "enter", type = "DoorEvent")]
    /**
     * @eventType DoorEvent.EXIT
     */
    [Event(name = "exit", type = "DoorEvent")]
    /**
     * Comment.
     */
    public class Center extends EventDispatcher {
    }
}

```

As you can see, meta-data may repeat (they are not unique) and certain meta-data may be preceded by an ASDoc comment (for example, for Apache Flex, `[Event]`), while any other compiler unrecognized meta-data propagates the preceding ASDoc comment to the annotatable directive (the class, or the variable, for example).

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [May 26, 2024, 9:40am UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/6 "2024-05-26T09:40:08Z")

</div>

Thank you. Have you looked into: [GitHub - tc39/proposal-decorator-metadata](https://github.com/tc39/proposal-decorator-metadata) ?

---

<div class="post-metadata">

**Author:** ![matheusds](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/matheusds/32/2093_2.png) [@matheusds](https://es.discourse.group/u/matheusds)\
**Post date:** [May 26, 2024, 3:46pm UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/7 "2024-05-26T15:46:42Z")

</div>

Interesting, I wasn't aware of this one. It seems to be a proposal intended for runtime inspection. I guess compilers about TypeScript are able to detect current decorators ahead of time and associate them as meta-data for influencing the program's AOT compilation.

I don't think TypeDoc comments were ever applied to decorators in TypeScript, or JSDoc comments applied to decorators in JavaScript. If this is not possible, I guess the meta-data decorator would need additional entries, along the lines of:

```ts
@Event({
    name: "enter",
    type: DoorEvent,
    constant: DoorEvent.ENTER,
    description: "Dispatched when",
})
class Center {}

```

You see, I didn't find it very readable. At the other hand, JSDoc and TypeDoc are diverging: TypeDoc supports the `@event` tag for a different purpose and doesn't treat it the same way.

Another thing to add is that using the `Event` name above for the decorator may cause name conflict between an imported `Event` class and an `Event` decorator. :(

---

<div class="post-metadata">

**Author:** ![hydroperfox](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/hydroperfox/32/2233_2.png) [@hydroperfox](https://es.discourse.group/u/hydroperfox)\
**Post date:** [September 23, 2024, 7:14pm UTC](https://es.discourse.group/t/documenting-dispatched-events/2043/8 "2024-09-23T19:14:46Z")

</div>

This is still sucking a lot for me since I don't use reactive models.
