Socket
Socket
Sign inDemoInstall

svelte-websocket-store

Package Overview
Dependencies
2
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-websocket-store

svelte store with a websocket backend


Version published
Weekly downloads
320
decreased by-29.36%
Maintainers
1
Install size
22.9 kB
Created
Weekly downloads
 

Readme

Source

Svelte v3 npm License bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status Tested with TestCafe

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

  • url string the WebSocket url
  • initialValue any store value used before 1st. response from server is present
  • socketOptions Array<string> transparently passed to the WebSocket constructor

Returns Store

install

With npm do:

npm install svelte-websocket-store

With yarn do:

yarn add svelte-websocket-store

run tests

export BROWSER=safari|chrome|...
npm|yarn test

license

BSD-2-Clause

Keywords

FAQs

Last updated on 14 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc