Skip to content

An Ember / Ember-CLI adapter for websockets via Phoenix channels.

License

BSD-2-Clause, MIT licenses found

Licenses found

BSD-2-Clause
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

BlakeWilliams/ember-phoenix-adapter

Repository files navigation

Ember-phoenix-adapter

An Ember CLI adapter for using Phoenix channels with Ember-Data.

Installation

$ ember install ember-phoenix-adapter

Usage

The adapter expects config/environment.js to define SocketURI for phoenix.js to connect to.

Adapters are configurable, you can define the joinParams which are sent when attempting to join a channel as well as the events to listen to for adding, updating, and removing records.

Here's an example adapter:

import PhoenixAdapter from "ember-phoenix-adapter";

export default PhoenixAdapter.extend({
  addEvents: ["add", "create"],

  joinParams: function() {
    return { authToken: token };
  }.property("token"),
});

Joining Channels

Each model using the adapter has to join a Phoenix channel of the same name, but pluralized.

ex: If you have a "post" model the adapter will attempt to join the posts channel.

You can specify the parameters sent when joining a channel by defining a joinParams property.

Listening to broadcasts

You can specify what events that the adapter listens to for updating, adding, and removing records via addEvents, updateEvents, and removeEvents.

  • addEvents defaults to ["add"]
  • updateEvents defaults to ["update"]
  • removeEvents defaults to ["remove"]

About

An Ember / Ember-CLI adapter for websockets via Phoenix channels.

Resources

License

BSD-2-Clause, MIT licenses found

Licenses found

BSD-2-Clause
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published