1.0.3 • Published 5 years ago

ember-phoenix v1.0.3

Weekly downloads
540
License
MIT
Repository
github
Last release
5 years ago

Ember-phoenix Build Status Ember Observer Score npm version

Greenkeeper badge

Installation

ember install ember-phoenix

Low-Level Use

You can import phoenix framework client-side utilities as an ES6 module

import { Socket } from 'ember-phoenix';

let socket = new Socket('/socket', {
  logger: ((kind, msg, data) => {
    console.log(`${kind}: ${msg}`, data);
  })
});

Recommended Use

Build a service around a socket (you will usually have only one, since phoenix multiplexes for you)

import PhoenixSocket from 'ember-phoenix/services/phoenix-socket';

export default PhoenixSocket.extend({

  init() {
    // You may listen to open, "close" and "error"
    this.on('open', () => {
      console.log('Socket was opened!');
    })
  },

  connect(/*url, options*/) {
    const myjwt = "abacnwih12eh12...";
    // connect the socket
    this._super("wss://myhost.com/socket/mysocket", {
      params: {token: myjwt}
    });

    // join a channel
    const channel = this.joinChannel("room:123", {
      nickname: "Mike"
    });

    // add message handlers
    channel.on("notification", () => _onNotification(...arguments));
  },

  _onNotification(message) {
    alert(`Notification: ${message}`);
  }
});

Contributing

  • git clone this repository
  • npm install
  • bower install

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 http://www.ember-cli.com/.

Copyright

(c) 2016 Levanto Financial

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.7

6 years ago

0.1.6

7 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago