Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Svelte example #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update Svelte example #21

wants to merge 1 commit into from

Conversation

notpushkin
Copy link

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}

@glitch-txs
Copy link
Contributor

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

@notpushkin
Copy link
Author

@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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants