Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace prefillService

Helper functions for offline handling

import { prefillService } from '@oneblink/apps'

Index

Functions

  • getPrefillFormData<T>(formId: number, prefillFormDataId: undefined | null | string): Promise<T | null>
  • Get prefill data for a form. Checks if the data is stored locally first, and then downloads from remote if required. After a successful download from the remote store, it will store is locally to ensure the next request will retrieve the data from the local store.

    const formId = 1
    const prefillFormDataId = '24faee0a-dca1-4c88-9100-9da2aae8e0ac'
    const prefillData = await prefillService.getPrefillFormData(
    formId,
    prefillFormDataId,
    )
    if (prefillData) {
    // prefill form with data
    }

    Type parameters

    • T: Record<string, unknown>

    Parameters

    • formId: number
    • prefillFormDataId: undefined | null | string

    Returns Promise<T | null>

  • removePrefillFormData(prefillFormDataId: string): Promise<void>
  • Remove prefill data form the local store.

    const prefillFormDataId = '24faee0a-dca1-4c88-9100-9da2aae8e0ac'
    await prefillService.removePrefillFormData(prefillFormDataId)

    Parameters

    • prefillFormDataId: string

    Returns Promise<void>