Sha256: 4f03d9256d8a70bdce00d57e10d92010a4d2e45aee7d537b6b30b070d48514ee
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
# opal-phoenix [![Gem Version](https://badge.fury.io/rb/opal-phoenix.svg)](http://badge.fury.io/rb/opal-phoenix) [![Code Climate](https://codeclimate.com/github/fazibear/opal-phoenix/badges/gpa.svg)](https://codeclimate.com/github/fazibear/opal-phoenix) Opal wrapper for [Phoenix Framework](http://phoenixframework.org) javascript library. ## usage ### Server side config.ru, Rakefile, Rails, Sinatra, etc. ```ruby require 'opal-phoenix' ``` Gemfile ```ruby gem 'opal-phoenix' ``` ### Browser side ```ruby require 'phoenix' # setup socket socket = Phoenix::Socket.new('ws://localhost:4000/ws', params: {some: 'param'}) socket.on_error do $console.log 'socket error!' end socket.on_close do $console.log 'socket closed!' end # connect to socket socket.connect # setup channel channel = socket.channel('lobby', other: 'param') channel.on_error do $console.log 'channel error!' end channel.on_close do $console.log 'channel closed!' end channel.on 'msg' do |payload| $console.log "payload: #{payload}" end # join channel channel .join .receive('ok') { $console.log 'ok' } .receive('failed') { $console.log 'failed' } # push a message channel .push("msg", {a: :b}) .receive('ok') { $console.log 'ok' } .receive('failed') { $console.log 'failed' } ```
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
opal-phoenix-0.0.8 | README.md |
opal-phoenix-0.0.7 | README.md |
opal-phoenix-0.0.6 | README.md |
opal-phoenix-0.0.5 | README.md |
opal-phoenix-0.0.4 | README.md |