# How to discuss between two controllers?

**URL:** <https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490>\
**Category:** General\
**Created:** [October 22, 2018, 3:41pm UTC](https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490 "2018-10-22T15:41:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kud](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/kud/32/333_2.png) [@kud](https://discuss.hotwired.dev/u/kud)\
**Post date:** [October 22, 2018, 3:41pm UTC](https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490/1 "2018-10-22T15:41:37Z")

</div>

I’d like to know how you discuss between two (or more) controllers?

I don’t speak about a parent and a child but two different controllers like we can with redux or whatever in React.

Do you have any example?

---

<div class="post-metadata">

**Author:** ![Stav](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/stav/32/344_2.png) [@Stav](https://discuss.hotwired.dev/u/Stav)\
**Post date:** [October 22, 2018, 4:29pm UTC](https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490/2 "2018-10-22T16:29:38Z")

</div>

There about many pubsub solutions out there. Maybe you could describe your specific case in more detail?

---

<div class="post-metadata">

**Author:** ![alinnert](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/alinnert/32/364_2.png) [@alinnert](https://discuss.hotwired.dev/u/alinnert)\
**Post date:** [October 26, 2018, 9:08am UTC](https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490/3 "2018-10-26T09:08:49Z")

</div>

I’ve created my own Custom Event Dispatcher. It’s heavily based on this article: [https://atech.blog/atech/creating-a-simple-custom-event-system-in-javascript](https://atech.blog/atech/creating-a-simple-custom-event-system-in-javascript)

---

<div class="post-metadata">

**Author:** ![kud](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/kud/32/333_2.png) [@kud](https://discuss.hotwired.dev/u/kud)\
**Post date:** [October 26, 2018, 9:30am UTC](https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490/4 "2018-10-26T09:30:07Z")

</div>

Thanks!

Yeah I used to have an Orchestrator when I did some Backbone.js. I’ll do the same here I think. 🙂

---

<div class="post-metadata">

**Author:** ![garrettqmartin](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/garrettqmartin/32/366_2.png) [@garrettqmartin](https://discuss.hotwired.dev/u/garrettqmartin)\
**Post date:** [October 31, 2018, 9:14pm UTC](https://discuss.hotwired.dev/t/how-to-discuss-between-two-controllers/490/5 "2018-10-31T21:14:49Z")

</div>

If you’d like to access one controller from another, you can do the following:

```
import { Controller } from "stimulus"

export default class extends Controller {
  //...

  get otherController() {
    return this.application.getControllerForElementAndIdentifier(document.querySelector(".elementSelector"), "controller-name")
  }
}

```

This was [discussed on Github](https://github.com/stimulusjs/stimulus/issues/35).
