https://github.com/mike-north/ember-phoenix
Phoenix Framework integration and tooling for Ember.js apps
https://github.com/mike-north/ember-phoenix
elixir emberjs phoenix-framework websocket
Last synced: 10 months ago
JSON representation
Phoenix Framework integration and tooling for Ember.js apps
- Host: GitHub
- URL: https://github.com/mike-north/ember-phoenix
- Owner: mike-north
- License: mit
- Created: 2016-02-16T17:54:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-12T20:36:51.000Z (over 1 year ago)
- Last Synced: 2025-05-01T12:04:58.380Z (about 1 year ago)
- Topics: elixir, emberjs, phoenix-framework, websocket
- Language: JavaScript
- Size: 1.52 MB
- Stars: 138
- Watchers: 7
- Forks: 25
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Ember-phoenix [](https://travis-ci.org/mike-north/ember-phoenix) [](https://emberobserver.com/addons/ember-phoenix) [](https://badge.fury.io/js/ember-phoenix)
[](https://greenkeeper.io/)
## Installation
```
ember install ember-phoenix
```
## Low-Level Use
You can import phoenix framework client-side utilities as an ES6 module
```js
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)
```js
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
* `ember server`
* Visit your app at http://localhost:4200.
## 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/](http://www.ember-cli.com/).
## Copyright
(c) 2016 Levanto Financial