Class TJSDocument<T>
Type Parameters
Index
Constructors
Accessors
Methods
Constructors
constructor
- new TJSDocument<T = NamedDocumentConstructor>(
document?: T | TJSDocumentOptions,
options?: TJSDocumentOptions,
): TJSDocument<T> Type Parameters
Parameters
Optional
document: T | TJSDocumentOptionsDocument to wrap or TJSDocumentOptions.
Optional
options: TJSDocumentOptionsTJSDocument options.
Returns TJSDocument<T>
Accessors
embedded
- get embedded(): EmbeddedAPI
Returns EmbeddedAPI
Embedded store manager.
updateOptions
- get updateOptions(): TJSDocumentUpdateOptions
Returns the options passed on last update.
Returns TJSDocumentUpdateOptions
Last update options.
uuidv4
- get uuidv4(): string
Returns the UUID assigned to this store.
Returns string
UUID
Methods
destroy
get
set
- set(document: T, options?: TJSDocumentUpdateOptions): void
Parameters
- document: T
New document to set.
Optional
options: TJSDocumentUpdateOptionsNew document update options to set.
Returns void
- document: T
setFromDataTransfer
- setFromDataTransfer(
data: object,
options?: { compendium?: boolean; types?: string[]; world?: boolean },
): Promise<boolean> Potentially sets new document from data transfer object.
Parameters
- data: object
Document transfer data.
Optional
options: { compendium?: boolean; types?: string[]; world?: boolean }Optional parameters for TJSDocument.getUUIDFromDataTransfer.
Returns Promise<boolean>
Returns true if new document set from data transfer blob.
- data: object
setFromUUID
- setFromUUID(uuid: string, options?: TJSDocumentUpdateOptions): Promise<boolean>
Sets the document by Foundry UUID performing a lookup and setting the document if found.
Parameters
- uuid: string
A Foundry UUID to lookup.
Optional
options: TJSDocumentUpdateOptionsNew document update options to set.
Returns Promise<boolean>
True if successfully set document from UUID.
- uuid: string
setOptions
- setOptions(options: TJSDocumentOptions): void
Sets options for this document wrapper / store.
Parameters
- options: TJSDocumentOptions
Options for TJSDocument.
Returns void
- options: TJSDocumentOptions
subscribe
- subscribe(
handler: (value: T, updateOptions?: TJSDocumentUpdateOptions) => void,
): Unsubscriber Parameters
- handler: (value: T, updateOptions?: TJSDocumentUpdateOptions) => void
Callback function that is invoked on update / changes.
Returns Unsubscriber
Unsubscribe function.
- handler: (value: T, updateOptions?: TJSDocumentUpdateOptions) => void
Static
getUUIDFromDataTransfer
- getUUIDFromDataTransfer(
data: object,
opts?: { compendium?: boolean; types?: string[]; world?: boolean },
): string Attempts to create a Foundry UUID from standard drop data. This may not work for all systems.
Parameters
- data: object
Drop transfer data.
Optional
opts: { compendium?: boolean; types?: string[]; world?: boolean }Optional parameters.
Returns string
Foundry UUID for drop data.
- data: object
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.