🔥 Firebase Svelte v2

createNodeStore()

createNodeStore<T>(realtimeDb, ref, options) creates a store based on a node reference. The store will update when the node changes.

Parameters

  • rtdb: Database - The realtime database instance. If you put the component at the root of your app, or higher than where you're using this store, you can use null or undefined as the parameter and the store will retrieve the database instance from the context.
  • ref: string | DatabaseReference - The database node reference to create the store from. Can be a string, just like posts/123 or a DatabaseReference object, using the ref database function.
  • options?: NodeStoreOptions<T> - Options for the store.

Properties

  • subscribe: ((val: T) => void)) => void; - Subscribe method for the Svelte store. Allows for the `$store` syntax.
  • ref: DatabaseReference - The node reference used to create the store.
  • key: string - The node key
  • loading: boolean - If the node is loading (undefined)
  • error: Error | null - Error if any
  • set: (val: T) => Promise<void>
  • update: (val: T) => Promise<void>

Types

interface NodeStoreOptions<T> { log?: boolean; once?: boolean; startValue?: T; }