Skip to content

Commit

Permalink
Merge pull request #59 from Naomak/master
Browse files Browse the repository at this point in the history
Remove deprecated sendAction()
  • Loading branch information
oskarrough authored Jul 16, 2019
2 parents 76b330b + 2982ae2 commit 2cda06b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
39 changes: 35 additions & 4 deletions addon/components/ember-youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,37 @@ export default Component.extend({
player: null,
playerState: 'loading',

/* Hooks */
playerCreated() {
/* Callback to be passed. */
},
playerStateChanged() {
/* Callback to be passed. */
},
error() {
/* Callback to be passed. */
},

/* State hooks */
ready() {
/* Callback to be passed. */
},
ended() {
/* Callback to be passed. */
},
playing() {
/* Callback to be passed. */
},
paused() {
/* Callback to be passed. */
},
buffering() {
/* Callback to be passed. */
},
queued() {
/* Callback to be passed. */
},

init() {
this._super();

Expand Down Expand Up @@ -107,7 +138,7 @@ export default Component.extend({
playerState: 'ready'
});

this.sendAction('playerCreated', player);
this.playerCreated(player);

this.loadVideo();
} catch(err) {
Expand Down Expand Up @@ -181,8 +212,8 @@ export default Component.extend({
debug(state);
}
// send actions outside
this.sendAction(state, event);
this.sendAction('playerStateChanged', event);
this[state](event);
this.playerStateChanged(event);
// send actions inside
this.send(state);
},
Expand All @@ -192,7 +223,7 @@ export default Component.extend({
let errorCode = event.data;
this.set('playerState', 'error');
// Send the event to the controller
this.sendAction('error', errorCode);
this.error(errorCode);
if (this.get('showDebug')) {
debug('error' + errorCode);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
delegate=this
delegate-as="emberYoutube"

playing="ytPlaying"
paused="ytPaused"
ended="ytEnded"}}
playing=(action "ytPlaying")
paused=(action "ytPaused")
ended=(action "ytEnded")
}}
</section>

<p>Multiple players on the same route are supported as well.</p>
Expand Down

0 comments on commit 2cda06b

Please sign in to comment.