Broadcast Channel
Reactive Broadcast Channel.
🎬 Usage
<script>
import {broadcast_channel} from "sveltecore"
const {data, post, error} = broadcast_channel()
$: if ($data) alert($data)
let value = "HI"
</script>
<h1>Open new Tab, and start a broadcaset :)</h1>
<input type="text" bind:value />
<button on:click="{() => post(value)}">Post</button>
👩💻API
Options
| Name | Description | Type | Default |
|---|---|---|---|
| name | The name of the broadcast channel | string | "" |
Returns
| Name | Description | Type |
|---|---|---|
| is_supported | Is the browser support broadcast channel | Readable<boolean> |
| is_closed | Is the broadcast channel closed | Readable<boolean> |
| data | The data from the broadcast channel | Readable<any | undefined> |
| error | The error from the broadcast channel | Readable<Event | null> |
| close | Close the broadcast channel | () => void |
| post | Post a function to the broadcast channel | (data: any) => void |
| channel | The broadcast channel | Readable<BroadcastChannel | undefined> |
🧪 Playground
Last update: 2022-11-12
Authors: Mohamed-Kaizen