Have ideas to improve npm?Join in the discussion! »

    ember-faye

    0.0.3 • Public • Published

    Ember-Faye

    Ember Faye is an ember-cli addon that seamlessly integrates Faye realtime messaging into Ember application.

    Installation

    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);
      }
    });
     

    Running

    Running Tests

    • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
    • ember test
    • ember test --server

    Building

    • ember build

    For more information on using ember-cli, visit ember-cli.

    © Alex Semyonov, @alsemyonov, <alex@semyonov.us>, 2016, MIT license.

    Install

    npm i ember-faye

    DownloadsWeekly Downloads

    3

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • avatar