Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coingaming/phoenix_live_view_singleton
https://github.com/coingaming/phoenix_live_view_singleton
Last synced: about 15 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/coingaming/phoenix_live_view_singleton
- Owner: coingaming
- Created: 2019-09-21T09:12:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-15T17:07:50.000Z (over 3 years ago)
- Last Synced: 2024-11-16T22:05:25.382Z (4 days ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# phoenix_live_view_singleton
The Phoenix LiveView JavaScript singleton client. Useful for adding hooks after init.
## Installation
```shell
npm i phoenix_live_view_singleton
```## Usage
Add some hook
```javascript
// file foo.jsimport liveView from "phoenix_live_view_singleton"
liveView.hooks.SomeHook = {
..
}
```Add more hooks in other file
```javascript
// file bar.jsimport liveView from "phoenix_live_view_singleton"
liveView.hooks.OtherHook = {
..
}liveView.hooks.AndMore = {
..
}
```Connect somewhere
```javascript
// file buz.jsimport liveView from "phoenix_live_view_singleton"
liveView.connect()
console.log(liveView.hooks)
// {
// SomeHook: {..},
// OtherHook: {..},
// AndMore: {..}
// }
```