Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/coingaming/phoenix_live_view_singleton


https://github.com/coingaming/phoenix_live_view_singleton

Last synced: about 15 hours ago
JSON representation

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.js

import liveView from "phoenix_live_view_singleton"

liveView.hooks.SomeHook = {
..
}
```

Add more hooks in other file
```javascript
// file bar.js

import liveView from "phoenix_live_view_singleton"

liveView.hooks.OtherHook = {
..
}

liveView.hooks.AndMore = {
..
}
```

Connect somewhere
```javascript
// file buz.js

import liveView from "phoenix_live_view_singleton"

liveView.connect()

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