Menu
Libraries |
Category

svelte-writable-derived

  • A Svelte-specific library that provides a read-write variant of Svelte's derived stores (v3 and v4 compatible)
  • Extends Svelte's derived stores with bidirectional functionality, allowing values to be sent back to source stores
  • Primary export: writableDerived() - creates a store that works like Svelte's derived but adds a reflect callback to propagate values back to origins
  • Secondary export: propertyStore() - utility wrapper for easily creating stores from object properties (supports nested paths)
  • Maintains Svelte's subscription behavior (only subscribes to origins when the derived store has subscribers)
  • Designed for scenarios where you need two-way synchronization between stores (e.g., JSON ↔ object conversion, object property access, or combining multiple stores)
  • Includes comprehensive examples demonstrating common use cases:
    • JSON string ↔ object conversion
    • Object property access (including arrays and nested objects)
    • Combining multiple stores into an object store
    • Complex chaining of store transformations
  • Browser compatibility matches Svelte's requirements (may need transpilers/polyfills for older environments)

Target audience: Svelte developers who need more flexible store interactions beyond standard derived stores, particularly when two-way data binding between stores is required.

sveltesvelte3

Comments