Skip to content

freshteapot/svelte-shared-store-custom-elements

Repository files navigation

Sharing svelte store across two customElements

What

  • shared svelte store
  • components use it for dev
  • compiled the build step skips adding it to the module

Show me

  • install dependencies
npm install
  • build the "superstore".
rollup -c rollup.config.store.js
  • run develop
npm run develop
  • open localhost:3000
  • click on "the count is 0"
  • watch both change
  • Open developer tools
  • type
superstore.count.subscribe(value => a = value)
  • type and observe number matches count
a
  • click on "the count is X"
  • type and observe number matches count
a

View via docker

Run

docker run --name svelte-shared-store \
-p 8080:80 \
-v $PWD/build:/usr/share/nginx/html:ro \
-v $PWD/nginx.conf:/etc/nginx/nginx.conf:ro \
-P -d nginx:1.17-alpine

Delete

docker container rm --force svelte-shared-store

About

Sharing a store across custom elements

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published