0.3.0 • Published 5 years ago

phoenix_live_view_singleton v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

phoenix_live_view_singleton

The Phoenix LiveView JavaScript singleton client. Useful for adding hooks after init.

Installation

npm i phoenix_live_view_singleton

Usage

Add some hook

// file foo.js

import liveSocket from "phoenix_live_view_singleton"

liveView.hooks.SomeHook = {
  ..
}

Add more hooks in other file

// file bar.js

import liveSocket from "phoenix_live_view_singleton"

liveView.hooks.OtherHook = {
  ..
}

liveView.hooks.AndMore = {
  ..
}

Connect somewhere

// file buz.js

import liveSocket from "phoenix_live_view_singleton"

liveSocket.connect()

console.log(liveSocket.hooks)
// {
//   SomeHook: {..},
//   OtherHook: {..},
//   AndMore: {..}
// }