Giter VIP home page Giter VIP logo

svelte-websocket-store's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

svelte-websocket-store's Issues

Dev run automatically connects to Node

When running my app with yarn run start, the websocketStore connects to localhost:38535 regardless of what I have in the url parameter:

import websocketStore from 'svelte-websocket-store';
let myStore = websocketStore("ws://localhost:8080/ws", initialValue, []);

I am using the websocket store with a Go backend, not Node, so this is not helpful in my situation, though I can see how it would be if I were using Node. It does connect to my specified URL as well, but any commands seem to be sent to only the Node server Yarn is running.

Is there a way to disable this behaviour?

(!) Missing global variable name

(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
svelte-websocket-store (guessing 'websocketStore') ver 1.1.3

SvelteKit and undefined readyState

I try to use this library, but I get error in browser:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'readyState')
at Object.set (index.mjs:80:18)

My code:

const initialValue = { };

if (browser) {
    const myStore = websocketStore("ws://localhost:3000/foo", initialValue);
    myStore.set({
        content: "to be saved",
        other_values: "all"
    });
}

I use latest Svelte's:

❯ npm list
[email protected] /home/jacek/storage/developSSD/epsvelte
├── @sveltejs/[email protected]
├── [email protected]
└── [email protected]

Add setup guide for Jest and this library

In my Svelte app running test with Jest fails because the index file is of this library is of type 'mjs'.

The following error is thrown:

> jest src

 FAIL  src/App.test.js
  ● Test suite failed to run

    Cannot find module 'svelte-websocket-store' from 'src/App.svelte'

It would be nice if you could add a section to the Readme explaining how to setup Jest properly to work with this library.

The following packages did not export their `package.json` file

[rollup-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.

- svelte-websocket-store

LiveReload enabled
created public/build/bundle.js in 321ms

[2021-02-13 06:25:39] waiting for changes...

[rollup-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.

- svelte-websocket-store

LiveReload enabled
(!) Plugin node-resolve: Could not resolve import "svelte-websocket-store/src/index.mjs" in /Users/test/github/svelte-huobi-client-app/src/App.svelte using exports defined in /Users/test/github/svelte-huobi-client-app/node_modules/svelte-websocket-store/package.json.
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
svelte-websocket-store/src/index.mjs (imported by src/App.svelte)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
svelte-websocket-store/src/index.mjs (guessing 'websocketStore')
created public/build/bundle.js in 343ms

Error on import?

I get the following error when trying to import this module.

internal/modules/cjs/loader.js:984
    throw new ERR_REQUIRE_ESM(filename);
    ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\...\node_modules\svelte-websocket-store\src\index.mjs
    at Module.load (internal/modules/cjs/loader.js:984:11)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\...\__sapper__\dev\server\server.js:10:38)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'ERR_REQUIRE_ESM'
}

I'm not sure what's going on here? I'm using this line in my Sapper route code:

import websocketStore from 'svelte-websocket-store'
```

Prep for serverside

If added to a sveltekit page/component that SSR then it fails.

Suggest to make it check if not browser and handle exit gracefully

Suggest drop forced json

There's really no need for forced JSON? Let it be up to the usecsse. Maybe a derived version forcing json?

ReferenceError: WebSocket is not defined

file:///{{url}}/node_modules/svelte-websocket-store/src/index.mjs:54
socket = new WebSocket(url, socketOptions);
^

ReferenceError: WebSocket is not defined
at open (file:///{{url}}/node_modules/svelte-websocket-store/src/index.mjs:54:5)
at Object.subscribe (file:///{{url}}/node_modules/svelte-websocket-store/src/index.mjs:84:7)
at Proxy.subscribe (/{{url}}/node_modules/svelte/internal/index.js:59:25)
at eval (/src/routes/dashboard.svelte:36:48)
at Object.$$render (/{{url}}/node_modules/svelte/internal/index.js:1758:22)
at Object.default (/.svelte-kit/generated/root.svelte:58:129)
at eval (/src/routes/__layout.svelte:85:75)
at Object.$$render (/{{url}}/node_modules/svelte/internal/index.js:1758:22)
at eval (/.svelte-kit/generated/root.svelte:50:126)
at $$render (/{{url}}/node_modules/svelte/internal/index.js:1758:22)

Node.js v18.2.0

Online status

Any way to show a status if websocket is open or closed to allow for an alert in ui?

Is it possible to use this with non JSON endpoints?

For example, I'd like to use this with @polkadot/api@beta, instead of the current setup of my store as below:

import { readable } from 'svelte/store';

const { ApiPromise, WsProvider } = require('@polkadot/api');
const wsProvider = new WsProvider('wss://kusama-rpc.polkadot.io/');
let api = ApiPromise.create({ provider: wsProvider });

export const getTotalIssuance = readable(null, async function start(set) {
    
    set(await (await api).query.balances.totalIssuance());

	return function stop() {};
});

export const getGenesisHash = readable(null, async function start(set) {
    
    set((await api).genesisHash.toHex());

	return function stop() {};
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.