Remove a draft from the local store and sync with remote drafts.
const draftId = 'd3aeb944-d0b3-11ea-87d0-0242ac130003'
await draftService.deleteDraft(draftId)
Get a single Draft and the associated submission data.
const draftId = 'd3aeb944-d0b3-11ea-87d0-0242ac130003'
const { draft, draftData, lastElementUpdated } =
await draftService.getDraftAndData(draftId)
// use "draftData" to prefill a from
Get an array of Drafts for the currently logged in user.
const drafts = await draftService.getDrafts()
Register a listener function that will be passed an array of Drafts when a draft is added, updated or deleted.
const listener = async (drafts) => {
// use drafts here...
}
const deregister = await draftService.registerDraftsListener(listener)
// When no longer needed, remember to deregister the listener
deregister()
Register a listener function that will be passed an array of Drafts when a draft is added, updated or deleted.
const listener = async (drafts) => {
// use drafts here...
}
const deregister = await draftService.registerDraftsListener(listener)
// When no longer needed, remember to deregister the listener
deregister()
Force a sync of remote drafts with locally stored drafts. This function will
swallow all errors thrown unless true
is passed for the throwError
property.
await draftService.syncDrafts({
throwError: true,
formsAppId: 1,
})
Signal to abort the requests
The id of the OneBlink Forms App to sync drafts with
true
to throw errors while syncing
Create or update a Draft in the local store and sync it with remote drafts.
Will also handle cleaning up auto save data (if the autoSaveKey
property is
passed).
const abortController = new AbortController()
const formSubmissionDraftId = 'd3aeb944-d0b3-11ea-87d0-0242ac130003' // pass `undefined` to create a new draft
const autoSaveKey = 'SET ME TO DELETE AUTOSAVE DATA AFTER SAVING DRAFT'
const draftSubmissionInput = {
title: 1,
formsAppId: 1,
submission: {
form: 'data',
goes: 'here',
},
definition: {
form: 'definition',
goes: 'here',
},
}
await draftService.upsertDraft({
formSubmissionDraftId,
autoSaveKey,
draftSubmissionInput,
abortSignal: abortController.signal,
onProgress: (progress) => {
// ...
},
})
Draft Service
Helper functions for handling drafts.