Class TJSDocument<D>
Type Parameters
- D extends ClientDocument
Foundry Document.
Constructors
constructor
-
new TJSDocument<D extends ClientDocument>(
document?: D | TJSDocument.Options.Config<D>,
options?: TJSDocument.Options.Config<D>,
): TJSDocument<D>Type Parameters
- D extends ClientDocument
Foundry Document.
Parameters
Optionaldocument: D | TJSDocument.Options.Config<D>Document to wrap or TJSDocumentOptions.
Optionaloptions: TJSDocument.Options.Config<D>TJSDocument options.
Returns TJSDocument<D>
- D extends ClientDocument
Accessors
embedded
-
Returns TJSDocument.API.Embedded
Embedded store manager.
updateOptions
-
Returns TJSDocument.Data.Update
Returns the options passed on last update.
uuidv4
-
get uuidv4(): string
Returns string
Returns the UUIDv4 assigned to this store.
Methods
destroy
-
Completely removes all internal subscribers, any optional delete callback, and unregisters from the ClientDocumentMixin
appstracking object.Returns void
get
-
Returns D
Current document
set
-
Sets a new document target to be monitored. To unset use
undefinedornull.Parameters
- doc: D
New document to set.
Optionaloptions: Partial<TJSDocument.Data.Update>New document update options to set.
Returns void
- doc: D
setFromDataTransfer
-
Potentially sets new document from data transfer object.
Parameters
- data: UUIDDataTransfer
Document transfer data.
Optionaloptions: UUIDFromDataTransferOptional parameters for TJSDocument.getUUIDFromDataTransfer.
Returns Promise<boolean>
Returns true if new document set from data transfer blob.
- data: UUIDDataTransfer
setFromUUID
-
Sets the document by Foundry UUID performing a lookup and setting the document if found.
Parameters
Optionaluuid: stringA Foundry UUID to lookup.
Optionaloptions: TJSDocument.Data.UpdateNew document update options to set.
Returns Promise<boolean>
True if successfully set document from UUID.
setOptions
-
Sets options for this document wrapper / store.
Parameters
- options: TJSDocument.Options.Config<D>
Options for TJSDocument.
Returns void
- options: TJSDocument.Options.Config<D>
subscribe
-
Parameters
- handler: TJSDocument.SubscriberFn<D>
Callback function that is invoked on update / changes.
Returns Unsubscriber
Unsubscribe function.
- handler: TJSDocument.SubscriberFn<D>
StaticgetUUIDFromDataTransfer
-
Attempts to create a Foundry UUID from standard drop data. This may not work for all systems.
Parameters
- data: UUIDDataTransfer
Drop transfer data.
Optionalopts: UUIDFromDataTransferOptional parameters.
Options for the TJSDocument.getUUIDFromDataTransfer and TJSDocument.setFromDataTransfer methods.
-
Optionalcompendium?: booleanAccept compendium documents.
-
Optionaltypes?: string[]Require the
data.typeto match an entry intypes. -
Optionalworld?: booleanAccept world documents.
-
Returns string
Foundry UUID for drop data.
- data: UUIDDataTransfer
Provides a wrapper implementing the Svelte store / subscriber protocol around any Document / ClientMixinDocument. This makes documents reactive in a Svelte component, but otherwise provides subscriber functionality external to Svelte.