// Subscribe to any changes in its data (markers, tours, etc) image.data.subscribe(data=> { // Data for this image been set, removed or changed // This also triggers when the image data has been loaded from the server if(data) console.log(`The image now has ${data.markers.length} markers`); elseconsole.log('The image data is now empty.'); });
// Let's set the image data to something. It expects ImageData. image.data.set({ markers: [{ "title": "My First Marker", "x": .5, "y": .5 }] });
// Immediately access the data console.log('The data has been set to', image.$data);
Svelte stores in Micrio
Micrio uses Svelte Stores for its internal state management.
This means that changes in values can passively trigger state updates.
There are two types of stores: Readable, which is read-only for the user, and Writable which can be updated or overridden by the user.
Typically, for accessing the data directly instead of its store, Micrio offers
$
prefixes to any store properties:An example of setting and subscribing to the Micrio.MicrioImage.data writable store:
List of stores used by Micrio:
<micr-io>
Element<micr-io>.state
controllerMicrioImage
MicrioImage.state
controllerPackage
svelte
Author
These people
License
MIT https://github.com/sveltejs/svelte/blob/master/LICENSE.md
Link
https://svelte.dev/tutorial/writable-stores