phoenix_live_view_singleton
v0.3.0
Published
The Phoenix LiveView JavaScript singleton client. Useful for adding hooks dynamically.
Downloads
3
Readme
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: {..}
// }