An Ember CLI adapter for using Phoenix channels with Ember-Data.
$ ember install ember-phoenix-adapter
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"),
});
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.
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"]