Created
November 3, 2016 09:17
-
-
Save shellandbull/1bcab96d9d3f240305c5c33b580d0172 to your computer and use it in GitHub Desktop.
webchat example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { Route, inject } = Ember; | |
export default Route.extend({ | |
myWebchatService: inject.service(), | |
activate() { | |
this._super(...arguments); | |
this.get('myWebchatService').on('poll', (data) => this.store.pushPayload(data)); | |
}, | |
model(conversationContext) { | |
const service = this.get('myWebchatService'); | |
return service.createTicket().then(() => { | |
return service.createInteraction(); | |
}); | |
}, | |
afterModel() { | |
this.get('myWebchatService').startPolling(); | |
}, | |
deactivate() { | |
this._super(...arguments); | |
const service = this.get('myWebchatService'); | |
service.stopPolling(); | |
service.off('poll'); | |
}, | |
actions: { | |
onUserSubmittedNewMessage(text) { | |
return this.get('myWebchatService').createMessage({ text }); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment