Skip to content

Instantly share code, notes, and snippets.

@shellandbull
Created November 3, 2016 09:17
Show Gist options
  • Save shellandbull/1bcab96d9d3f240305c5c33b580d0172 to your computer and use it in GitHub Desktop.
Save shellandbull/1bcab96d9d3f240305c5c33b580d0172 to your computer and use it in GitHub Desktop.
webchat example
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