mipd icon indicating copy to clipboard operation
mipd copied to clipboard

Update Svelte example

Open notpushkin opened this issue 11 months ago • 3 comments

Svelte stores are just objects with a subscribe() method. This means you can use MIPD Store directly!

<script lang="ts">
  import { createStore } from 'mipd'

  const providers = createStore()
</script>

{#each $providers as provider}
  <!-- ... -->
{/each}

notpushkin avatar Mar 09 '25 11:03 notpushkin

providers is filled in dynamically with events, this needs to be reactive.

glitch-txs avatar Mar 09 '25 19:03 glitch-txs

@glitch-txs If I understand correctly how providers.subscribe() works, then $providers is reactive in Svelte.

(It’s a syntax sugar: when you prefix store name with a $, component will call subscribe() on it and will be updating the value every time it gets it from the store.)

notpushkin avatar Mar 10 '25 09:03 notpushkin

@glitch-txs Please do let me know if you have more questions!

notpushkin avatar Mar 17 '25 16:03 notpushkin