svecosystem / runed

Magical utilities for your Svelte applications (WIP)
https://runed.dev
MIT License
461 stars 23 forks source link

feat: `useStore` #50

Closed mass8326 closed 3 months ago

mass8326 commented 4 months ago

Converts a legacy svelte store into boxed state. Useful when a library requires the use of a store but you would like to work with runes in your own code.

<script lang="ts">
    import { useStore } from "runed";
    import { writable } from "svelte/store";

    const store = writable(0);
    const boxed = useStore(store);
</script>

<div>
    <pre>Boxed: {boxed.value}</pre>
    <button onclick={() => boxed.value++}>Increment via boxed</button>
    <pre>Store: {$store}</pre>
    <button onclick={() => ($store = $store + 1)}>Increment via store</button>
</div>
changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: 93b80fcbbb5a548c7529b8dedaebe9dfa00d1d82

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----- | ----- | | runed | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

github-actions[bot] commented 4 months ago
built with Refined Cloudflare Pages Action

âš¡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ✅ Ready (View Log) Visit Preview 93b80fcbbb5a548c7529b8dedaebe9dfa00d1d82
TGlide commented 3 months ago

Thank you!