autosave#
Classes#
AutosaveError#
Defined in: editor/src/autosave.ts:33
IndexedDB is missing, or one of its requests failed; cause holds its error.
Extends#
Error
Constructors#
Constructor#
new AutosaveError(
code,key,message,cause?):AutosaveError
Defined in: editor/src/autosave.ts:37
Parameters#
code#
key#
string
message#
string
cause?#
unknown
Returns#
Overrides#
Error.constructor
Properties#
code#
readonlycode:AutosaveErrorCode
Defined in: editor/src/autosave.ts:34
key#
readonlykey:string
Defined in: editor/src/autosave.ts:35
Interfaces#
Autosave#
Defined in: editor/src/autosave.ts:73
The autosave of one slot: snapshots scheduled, written one after another.
Methods#
discard()#
discard():
void
Defined in: editor/src/autosave.ts:77
Drop the pending snapshot and empty the slot, after every write already started.
Returns#
void
flush()#
flush():
Promise<void>
Defined in: editor/src/autosave.ts:82
Write the pending snapshot now and wait for every write. Rejects with the first failure since the previous flush that no caller waited for.
Returns#
Promise<void>
schedule()#
schedule(
snapshot):void
Defined in: editor/src/autosave.ts:75
Write snapshot once no further snapshot was scheduled for delayMs.
Parameters#
snapshot#
Returns#
void
AutosaveOptions#
Defined in: editor/src/autosave.ts:46
What createAutosave is given: the slot, the delay and where unattended failures go.
Properties#
delayMs#
readonlydelayMs:number
Defined in: editor/src/autosave.ts:50
How long schedule waits for a later snapshot before writing.
key#
readonlykey:string
Defined in: editor/src/autosave.ts:48
The workspace’s slot.
onError?#
readonlyoptionalonError?: (error) =>void
Defined in: editor/src/autosave.ts:55
Told of a failure no caller waits for (a write the timer started, a
discard); without it, the failure is held and rejects the next flush().
Parameters#
error#
unknown
Returns#
void
Snapshot#
Defined in: editor/src/autosave.ts:62
What a slot holds: a workspace’s text, the name of its file and, where known, the file’s path on the server or, where kept, its handle.
Properties#
handle?#
readonlyoptionalhandle?:FileSystemFileHandle
Defined in: editor/src/autosave.ts:66
name#
readonlyname:string
Defined in: editor/src/autosave.ts:64
path?#
readonlyoptionalpath?:string
Defined in: editor/src/autosave.ts:65
text#
readonlytext:string
Defined in: editor/src/autosave.ts:63
Type Aliases#
AutosaveErrorCode#
AutosaveErrorCode =
"indexeddb_unavailable"|"indexeddb_failed"
Defined in: editor/src/autosave.ts:30
Why the autosave failed: IndexedDB is missing, or one of its requests failed.
Pending#
Defined in: editor/src/autosave.ts:70
A snapshot, or a function giving it when the write is due.
Functions#
clear()#
clear(
key):Promise<void>
Defined in: editor/src/autosave.ts:164
Remove the slot of key.
Parameters#
key#
string
Returns#
Promise<void>
createAutosave()#
createAutosave(
__namedParameters):Autosave
Defined in: editor/src/autosave.ts:86
An autosave of the slot key, writing a scheduled snapshot after delayMs without a later one.
Parameters#
__namedParameters#
Returns#
recoverWorkspace()#
recoverWorkspace(
key):Promise<Snapshot|null>
Defined in: editor/src/autosave.ts:150
The snapshot last written under key, or null when the slot holds none.
Parameters#
key#
string
Returns#
Promise<Snapshot | null>