A factory for creating models that encapsulate Svelte stores. Stores can be automatically subscribed to, with their values accessible from an attrs
object.
Here's a contrived example to demonstrate the API. A Pattern
is a model that can record
events, and schedule them to replay on repeat. The inner workings don't really matter here, but notice that active
, recordable
, and duration
are referenced on attrs
.
import { writable, derived } from 'svelte/store'
const Pattern = Model(function ({ stores, store, attrs, destroy }) {