# Cannot hook to events

**URL:** <https://discourse.mopidy.com/t/cannot-hook-to-events/4206>\
**Category:** Misc\
**Created:** [July 30, 2020, 9:32am UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206 "2020-07-30T09:32:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gkzsolt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/gkzsolt/32/1670_2.png) [@gkzsolt](https://discourse.mopidy.com/u/gkzsolt)\
**Post date:** [July 30, 2020, 9:32am UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206/1 "2020-07-30T09:32:31Z")

</div>

Hi there,

I am trying to hook to some events but no success so far.  
`mopidy.on(console.log.bind(console))` expects 2 arguments (` The "listener" argument must be of type Function. Received type undefined at checkListener`), so I cannot use it to list events. I tried:

```
mopidy.on("playback_state_changed", handler);

```

but nothing was received on playback start or stop. I don’t know if the event name is right, it should be prefixed with something (‘state:’, …), or how to find available valid event names. Can somebody help me?

Many thanks,

---

<div class="post-metadata">

**Author:** ![sapristi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/sapristi/32/1364_2.png) [@sapristi](https://discourse.mopidy.com/u/sapristi)\
**Post date:** [July 30, 2020, 7:32pm UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206/2 "2020-07-30T19:32:11Z")

</div>

Here’s a generic statement that will catch all events: `mopidyCli.on('event', console.log)`  
From there you can find events in console.

---

<div class="post-metadata">

**Author:** ![gkzsolt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/gkzsolt/32/1670_2.png) [@gkzsolt](https://discourse.mopidy.com/u/gkzsolt)\
**Post date:** [July 30, 2020, 7:40pm UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206/3 "2020-07-30T19:40:18Z")

</div>

Thank you very much, @sapristi ! That was what I needed.

(I think it would be useful to update this in the documentation. I can volunteer if given some indication.)

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [July 30, 2020, 8:14pm UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206/4 "2020-07-30T20:14:12Z")

</div>

Is this not already in the documentation at [https://github.com/mopidy/mopidy.js/#hooking-up-to-events](https://github.com/mopidy/mopidy.js/#hooking-up-to-events) ?

---

<div class="post-metadata">

**Author:** ![gkzsolt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/gkzsolt/32/1670_2.png) [@gkzsolt](https://discourse.mopidy.com/u/gkzsolt)\
**Post date:** [July 30, 2020, 9:05pm UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206/5 "2020-07-30T21:05:23Z")

</div>

Haha, I was looking at [release-2.3 docs](https://docs.mopidy.com/en/release-2.3/api/js/#mopidy-js). Btw, I have mopidy version 2.2.3 installed on my Raspberry PI, as offered by the Raspbian 9 Stretch package.  
Do you recommend installing v 3.0 ? (it seems I wouldn’t mind too much a development version.) Will it be possible on Stretch?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [July 30, 2020, 10:53pm UTC](https://discourse.mopidy.com/t/cannot-hook-to-events/4206/6 "2020-07-30T22:53:09Z")

</div>

I do recommend Mopidy v3, we don’t support v2.x any more. But, Stretch is too old - see [https://mopidy.com/blog/2019/12/27/mopidy-3-faq/#what-about-mopidy-3-on-debian-stretch](https://mopidy.com/blog/2019/12/27/mopidy-3-faq/#what-about-mopidy-3-on-debian-stretch)
