Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blakewilliams/ember-phoenix-adapter
An Ember / Ember-CLI adapter for websockets via Phoenix channels.
https://github.com/blakewilliams/ember-phoenix-adapter
Last synced: 2 months ago
JSON representation
An Ember / Ember-CLI adapter for websockets via Phoenix channels.
- Host: GitHub
- URL: https://github.com/blakewilliams/ember-phoenix-adapter
- Owner: BlakeWilliams
- License: bsd-2-clause
- Created: 2015-04-11T22:14:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-14T17:56:48.000Z (over 8 years ago)
- Last Synced: 2024-10-07T19:36:42.978Z (3 months ago)
- Language: JavaScript
- Size: 179 KB
- Stars: 24
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ember-phoenix-adapter
An Ember CLI adapter for using [Phoenix] channels with Ember-Data.
[Phoenix]: http://www.phoenixframework.org/
## 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:
```javascript
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"]`