# Como se inscrever para receber notificações de eventos (tópico criado, tópico fechado, etc.)

**URL:** <https://meta.discourse.org/t/how-to-subscribe-to-events-topic-created-topic-closed-etc/116242>\
**Category:** Development\
**Created:** [29 Abril , 2019 13:10 UTC](https://meta.discourse.org/t/how-to-subscribe-to-events-topic-created-topic-closed-etc/116242 "2019-04-29T13:10:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan.bacher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan.bacher/32/139602_2.png) [@Ivan.bacher](https://meta.discourse.org/u/Ivan.bacher)\
**Post date:** [29 Abril , 2019 13:10 UTC](https://meta.discourse.org/t/how-to-subscribe-to-events-topic-created-topic-closed-etc/116242/1 "2019-04-29T13:10:26Z")

</div>

I am currently creating a plugin and was wondering how to subscribe to different events.

`initializePlugin()` exposes an `api` object that has the function `onAppEvent(name, fn)`.

Is there a list somewhere with the name of the events one can subscribe to?

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [29 Abril , 2019 13:13 UTC](https://meta.discourse.org/t/how-to-subscribe-to-events-topic-created-topic-closed-etc/116242/2 "2019-04-29T13:13:09Z")

</div>

> [@Ivan.bacher](#):
>
> Is there a list somewhere with the name of the events one can subscribe to?

Your best shot at an up-to-date list is to grep the source code for these events.

---

<div class="post-metadata">

**Author:** ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)\
**Post date:** [1 Agosto , 2019 23:45 UTC](https://meta.discourse.org/t/how-to-subscribe-to-events-topic-created-topic-closed-etc/116242/3 "2019-08-01T23:45:54Z")

</div>

Qual é a melhor maneira de encontrá-los? Estou procurando por `onAppEvent`, mas isso não está retornando muito:

```plaintext
$ grep -r onAppEvent *
app/assets/javascripts/discourse/lib/plugin-api.js.es6: this.onAppEvent("page:changed", data => fn(data.url, data.title));
app/assets/javascripts/discourse/lib/plugin-api.js.es6: api.onAppEvent('inserted-custom-html', () => {
app/assets/javascripts/discourse/lib/plugin-api.js.es6: onAppEvent(name, fn) {
jsapp/lib/plugin-api.js.es6: this.onAppEvent("page:changed", data => fn(data.url, data.title));
jsapp/lib/plugin-api.js.es6: api.onAppEvent('inserted-custom-html', () => {
jsapp/lib/plugin-api.js.es6: onAppEvent(name, fn) {

```

---

<div class="post-metadata">

**Author:** ![phallguy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/phallguy/32/150760_2.png) [@phallguy](https://meta.discourse.org/u/phallguy)\
**Post date:** [20 Setembro , 2019 20:33 UTC](https://meta.discourse.org/t/how-to-subscribe-to-events-topic-created-topic-closed-etc/116242/4 "2019-09-20T20:33:42Z")

</div>

Eu também fiz uma pesquisa e descobri que buscar por `\.trigger\(` produziu uma lista de onde os eventos são realmente disparados.
