# Adicionando um mixin a uma classe em um plugin?

**URL:** <https://meta.discourse.org/t/adding-a-mixin-to-a-class-in-a-plugin/83905>\
**Category:** Development\
**Created:** [26 Março , 2018 20:30 UTC](https://meta.discourse.org/t/adding-a-mixin-to-a-class-in-a-plugin/83905 "2018-03-26T20:30:17Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![shoshber](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shoshber/32/95393_2.png) [@shoshber](https://meta.discourse.org/u/shoshber)\
**Post date:** [26 Março , 2018 20:30 UTC](https://meta.discourse.org/t/adding-a-mixin-to-a-class-in-a-plugin/83905/1 "2018-03-26T20:30:17Z")

</div>

I need to modify a javascript controller (`create-account`). If I were writing it from scratch, I’d add a mixin called something like (`FooValidation`), the same way the mixins `PasswordValidation` and `UsernameValidation` are applied ([discourse/app/assets/javascripts/discourse/controllers/create-account.js.es6 at f03b6bd8c925163b41b9e33b39484d102dbaee44 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/f03b6bd8c925163b41b9e33b39484d102dbaee44/app/assets/javascripts/discourse/controllers/create-account.js.es6#L13)). I can’t figure out how, though.

I _could_ just add the relevant properties/methods to the create account controller using `PluginApi.modifyClass`, but that doesn’t feel right, especially seeing as I’ll want to reuse the mixin.

What’s the best way to achieve this?

---

_[View the full topic](https://meta.discourse.org/t/adding-a-mixin-to-a-class-in-a-plugin/83905)._
