# Acionando uma função sempre que a categoria for alterada no composer

**URL:** <https://meta.discourse.org/t/triggering-a-function-whenever-the-category-is-changed-within-the-composer/388497>\
**Category:** Development\
**Created:** [14 Novembro , 2025 15:49 UTC](https://meta.discourse.org/t/triggering-a-function-whenever-the-category-is-changed-within-the-composer/388497 "2025-11-14T15:49:12Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![frye\_bradley](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@frye\_bradley](https://meta.discourse.org/u/frye_bradley)\
**Post date:** [14 Novembro , 2025 17:55 UTC](https://meta.discourse.org/t/triggering-a-function-whenever-the-category-is-changed-within-the-composer/388497/3 "2025-11-14T17:55:07Z")

</div>

Tentei esta solução, mas infelizmente parece que a versão em que estou construindo tem uma lista mais antiga de transformadores inicializados, que por acaso está faltando o `composer-editor-reply-placeholder`.

Para um pouco mais de contexto, estou refatorando os recursos do plugin para usar componentes Glimmer após a descontinuação da API `registerConnectorClass`. O código abaixo é o que foi configurado originalmente.

```plaintext
export default {
  initialize(container) {
    withPluginApi("1.6.0", api => {
      api.registerConnectorClass("composer-fields", "handlebars-template-name", {
        setupComponent(attrs, component) {
          const model = attrs.model;
          const controller = api.container.lookup("controller:composer");
          if (controller) {
            controller.addObserver("model.categoryId", this, function() {

              // lógica para definir valores para showToggle e isRestricted

              let props = {
                showField: showToggle && isRestricted,
              }
              component.setProperties(Object.assign(props));
            })
          }
        }
      }

```

Existe outra maneira de obter a mesma funcionalidade de um componente Glimmer? Especificamente observando mudanças no model e/ou categoryId.

---

_[View the full topic](https://meta.discourse.org/t/triggering-a-function-whenever-the-category-is-changed-within-the-composer/388497)._
