RexJS - elixir
RexJS is library for reactivity between elixir data and front-end through javascript websockets.
<img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/4eSXzM9Zem3cwXCYU3QciGaZ/orisons/rexjs-elixir.svg' />Installation
Elixir
Add rexjs to your list of dependencies in mix.exs:
def deps do
[{:rexjs, "~> 0.1.0"}]
endFront-end
Usage
Phoenix Framework:
Add to config.ex:
config :rexjsphoenix, YourPhoenixApp.Endpoint,
...
http: [dispatch: [
{:_, [
{"/rexjs", Orisons.RexJS.Adapter.Cowboy, []},
{:_, Plug.Adapters.Cowboy.Handler, {YourPhoenixApp.Endpoint, []}}
]}]]Cowboy:
:cowboy_router.compile([
{ :_,
[
{"/rexjs", Orisons.RexJS.Adapter.Cowboy, []}
{"/someurl", DynamicPageHandler, []},
]
}
])
You can change "/rexjs" endpoint to other, it's configurable in front-end.
Start worker
Orisons.RexJS.Module.start_worker("worker_unique_name")Set module data in worker
Orisons.RexJS.Module.set_data("worker_unique_name", "module_name", "Some value")This function post message with data to all binded websockets with this worker and module
More info you can find in documentation.