1.1.34 • Published 2 years ago
svelte-websocket-store v1.1.34
svelte-websocket-store
Svelte store with a websocket backend
import websocketStore from "svelte-websocket-store";
const initialValue = { };
export const myStore = websocketStore("wss://mydomain.com/ws1", initialValue, ['option 1', 'option 2']);
// send JSON to websocket server
$myStore = { content: "to be saved", other_values: "all" };
// receive JSON from server (push)
let response = $myStore;API
Table of Contents
websocketStore
Create a writable store based on a web-socket. Data is transferred as JSON. Keeps socket open (reopens if closed) as long as there are subscriptions.
Parameters
urlstring the WebSocket urlinitialValueany store value used before 1st. response from server is presentsocketOptionsArray[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) transparently passed to the WebSocket constructor
Returns Store
install
With npm do:
npm install svelte-websocket-storeWith yarn do:
yarn add svelte-websocket-storerun tests
export BROWSER=safari|chrome|...
npm|yarn testlicense
BSD-2-Clause
1.1.34
2 years ago
1.1.29
3 years ago
1.1.28
3 years ago
1.1.30
3 years ago
1.1.33
3 years ago
1.1.32
3 years ago
1.1.31
3 years ago
1.1.27
3 years ago
1.1.26
3 years ago
1.1.25
3 years ago
1.1.24
4 years ago
1.1.23
4 years ago
1.1.22
4 years ago
1.1.16
4 years ago
1.1.19
4 years ago
1.1.18
4 years ago
1.1.17
4 years ago
1.1.21
4 years ago
1.1.20
4 years ago
1.1.15
4 years ago
1.1.14
4 years ago
1.1.13
4 years ago
1.1.12
4 years ago
1.1.11
4 years ago
1.1.10
4 years ago
1.1.9
4 years ago
1.1.8
4 years ago
1.1.7
4 years ago
1.1.6
4 years ago
1.1.5
4 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago