Appearance
Persistence
Persistence is enabled by default. Disable it via super(defaults, { persist: false }).
Example:
ts
protected override getPersistenceDriver(suffix?: string): PersistenceDriver {
return new SessionStorageDriver(suffix)
}See the Persistence service for available drivers and custom implementations: Persistence.
Notes:
persistSuffixis passed togetPersistenceDriver(suffix)for namespacing.- Persisted state is restored through a restore policy. By default, Blueprint restores only when the stored
originalmatches your current defaults. persist: falsedisables automatic rehydration and background persistence.File/Blobvalues are not JSON-serializable and should use{ persist: false }.
Default Restore Behavior
The built-in StrictPersistenceRestorePolicy behaves like this:
- Blueprint asks the configured persistence driver for previously saved form state.
- If no persisted state exists, the form starts from the constructor defaults.
- If persisted state exists, Blueprint compares the persisted
originalvalue to the current constructor defaults. - If those values match, Blueprint restores:
- the persisted form
state - the persisted
original - the persisted
dirtyflags - the persisted
touchedflags
- the persisted form
- If they do not match, Blueprint discards the persisted entry and starts from the constructor defaults.
The comparison ignores persistence-only markers used by PropertyAwareObject, so property-aware structures are compared by their actual form data.
Restore Policy
Override getPersistenceRestorePolicy() when a form needs custom restore behavior:
ts
import {
BaseForm,
StrictPersistenceRestorePolicy,
type PersistenceRestorePolicy
} from '@blueprint-ts/core/vue/forms'
export class MyForm extends BaseForm<RequestPayload, FormState> {
protected override getPersistenceRestorePolicy(): PersistenceRestorePolicy<FormState> {
return new StrictPersistenceRestorePolicy<FormState>()
}
}The default implementation already returns StrictPersistenceRestorePolicy, so you only need to override this method when a form needs a custom policy.
Debug Logging
Persistence debug logging is disabled by default. Enable it by overriding shouldLogPersistenceDebug():
ts
export class MyForm extends BaseForm<RequestPayload, FormState> {
protected override shouldLogPersistenceDebug(): boolean {
return true
}
}When enabled, Blueprint logs:
- when no persisted state exists
- when persisted state is restored
- when persisted state is discarded and why
This is useful when debugging why a draft was not restored without enabling noisy logging for all forms.