Skip to Content
Isomorphic APIuseSyncOne

Available on client only

useSyncOne(basicFilter: EqualityFilter, syncOptions: SyncOneOptions, hookOptions?: HookOptions): AsyncResult

Retrieves the first row matching the filter and keeps it in sync

  • use { handlesOnData: true } to get optimistic updates method: $update
  • any changes to the row using the $update method will be reflected instantly to all sync subscribers that were initiated with the same syncOptions

Parameters

  • basicFilter required EqualityFilter

    Filter used for data synchronization, where all specified columns must match the given values.

    Columns are combined using an AND condition.

    Example: { department: 'd1', name: 'abc' } would match records where department is ‘d1’ AND name is ‘abc’.

  • syncOptions required SyncOneOptions

    • onChange optional MultiChangeListener

      Data change listener. Called on first sync and every time the data changes

    • skipFirstTrigger optional boolean

      If true then the first onChange trigger is skipped

    • select optional AnyObject | ”*” | undefined

    • storageType optional “object” | “array” | “localStorage” | undefined

      Default is “object”. “localStorage” will persist the data

    • patchText optional boolean

      If true then only the delta of the text field is sent to server. Full text is sent if an error occurs

    • patchJSON optional boolean

    • onReady optional () => void

    • handlesOnData optional boolean

  • hookOptions optional HookOptions

    • skip optional boolean

      Used to prevent the hook from fetching data

    • deps optional any[] | undefined

      Used to trigger re-fetching

Return type

AsyncResult

Async result type:

  • data: the expected data
  • isLoading: true when data is being fetched (initially or on subsequent filter/option changes)
  • error: any error that occurred
Last updated on