Skip to content

Commit

Permalink
📝 Add getEventEmitter example
Browse files Browse the repository at this point in the history
In #42 somebody required help because the implementation of `getEventEmitter` wasn't really that clear to end users. The example should clear that up.
  • Loading branch information
NeoLegends committed Jul 4, 2018
1 parent 87ee4c5 commit dd4524f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ cordova.plugins.spotify.getPosition()
.catch(() => console.log("Whoops, no track is playing right now."));
```

### React to events from native SKDs
```js
cordova.plugins.spotify.getEventEmitter()
.then(emitter => emitter.on('playbackevent', eventName => {
switch (eventName) {
case 'PlaybackNotifyPlay':
console.log("Playback was started");
break;
case 'PlaybackNotifyPause':
console.log("Playback was paused");
break;
default:
console.log("Some other event was raised:", eventName);
break;
}
}))
```

## Contributing

Pull requests are very welcome! Please use the [gitmoji](https://gitmoji.carloscuesta.me/) style for commit messages.

0 comments on commit dd4524f

Please sign in to comment.