mpdrx
Version:
MPD client events as stream
59 lines (47 loc) • 1.32 kB
Markdown
# node mpd client as RX.JS streams
Uses [mpd-api module](https://github.com/cotko/mpd-api) and exposes a few streams to subscribe to.
## Usage
```
npm i / yarn add mpdrx
```
```js
const log = tag => console.log.bind(console, tag)
const streams = await cl.connect()
const {
client, // reference to 'mpd-api' client
event$,
status$,
currentSong$,
currentSongUnique$,
playlists$,
message$,
dbUpdate$,
stats$,
partition$,
sticker$,
subscription$,
neighbor$,
mount$,
output$,
} = streams
.subscribe(log('event'))
.subscribe(log('status'))
// unique by `songid`
.subscribe(log('currentSong'))
// unique by `file` in case of duplicate songs in the queue
.subscribe(log('currentSongUnique'))
.subscribe(log('playlists'))
.subscribe(log('message'))
.subscribe(log('dbUpdate'))
.subscribe(log('stats'))
.subscribe(log('partition'))
.subscribe(log('sticker'))
.subscribe(log('subscription'))
.subscribe(log('neighbor'))
.subscribe(log('mount'))
.subscribe(log('output'))
setTimeout(async () => {
console.log('disconnecting...')
await client.disconnect()
}, 30000)
```