Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Is it possible to pass a Svelte store as a property on a component?

$
0
0

I’ve got a simple REPL example for a simple list-detail editor. It’s made up of three components:

  1. Annotation is the detail
  2. Annotations loops through the data and creates Annotation instances
  3. App is the top-level that creates the Annotations

I’ve figured out how to wire up a custom Svelte store to manage the Array of instance data for the Annotations. I can use this by importing the store directly into the Annotations component and calling it without any props from the top-level App component. However, I’d like to be able to pass the store in as a property on the Annotations component from the App parent, i.e. <Annotations items={store}/>, not <Annotations/>.

Is this possible? I would think that injecting the store from a parent component would be more flexible/testable than importing it from the component itself. Have I done too much dependency injection with Spring in Java and I’m thinking about the Svelte model incorrectly?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>