Ember Faye is an ember-cli
addon that seamlessly integrates Faye realtime messaging into Ember application.
- NPM:
- Github:
- Code quality:
- CI:
- Ember Addons: ember-faye
- Ember Observer: ember-faye
Install as usual ember-cli
addon:
ember install ember-faye
Configure it in config/environment.js
:
module.exports = function(environment) {
var ENV = {
/// ...
faye: {
URL: 'http://127.0.0.1:3000/faye',
options: {
timeout: 5
}
}
/// ...
};
return ENV;
};
In another service (or controller) you could subscribe to faye
channels like this:
// app/service/messenger.js
import Ember from 'ember';
export default Ember.Service.extend({
faye: Ember.inject.service(),
init() {
this._super(...arguments);
this.setup();
},
setup() {
let faye = this.get('faye');
let subscription = faye.subscribe('/some/channel', this.get('onMessage'), this);
return subscription;
},
onMessage(data, channel) {
console.debug(`Received message on channel "${channel}":`, data);
}
});
ember server
- Visit your app at http://localhost:4200.
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli
, visit ember-cli
.
© Alex Semyonov, @alsemyonov, <[email protected]>, 2016, .