ImFusion Web SDK

DataModel

Observable collection of datasets with unique names.

Extends

Methods

MethodDescription
loadFile()Loads a dataset with the given path from the wasm filesystem.
size()The number of datasets in the model.
data()Returns all datasets as a HandleArray.
get()Returns the dataset at the given index or null if the index is out of bounds.
includes()Returns true if the given dataset is in the data model.
find()Returns the dataset with the given name, or null if not found.
getImage()Returns the first SharedImageSet matching the given kind and modality.
getImages()Returns all SharedImageSets matching the given kind and modality.
add()Adds a dataset to the data model.
remove()Removes the given dataset from the DataModel.
clear()Removes all datasets from the DataModel.
onDataAdded()Fires when a dataset is added.
onDataAboutToBeRemoved()Fires directly before a dataset is removed.

Inherited from ClassHandle

MethodDescription
isAliasOf()Returns true if this handle and other alias the same underlying C++ object.
delete()Releases this JavaScript handle.
deleteLater()Schedules this handle for deferred deletion and returns this handle.
isDeleted()Returns true if this handle has already been deleted.
[dispose]()Releases this handle when the enclosing scope exits, so a handle can be declared with using instead of calling delete() later manually.
clone()Returns a new JavaScript handle aliasing the same underlying C++ object.

loadFile()

ts
loadFile(path: EmbindString, format?: FileFormat): HandleArray<Data>;

Loads a dataset with the given path from the wasm filesystem.

Parameters

ParameterTypeDescription
pathEmbindStringPath to file.
format?FileFormatThe file format. If omitted, tries to automatically detect it from the filename extension, then file content if no known extension is present.

Returns

HandleArray<Data>

List of loaded datasets.


size()

ts
size(): number;

The number of datasets in the model.

Returns

number


data()

ts
data(): HandleArray<Data>;

Returns all datasets as a HandleArray.

Returns

HandleArray<Data>


get()

ts
get(index: number): Data | null;

Returns the dataset at the given index or null if the index is out of bounds.

Parameters

ParameterType
indexnumber

Returns

Data | null


includes()

ts
includes(data: Data | null): boolean;

Returns true if the given dataset is in the data model.

Parameters

ParameterType
dataData | null

Returns

boolean


find()

ts
find(name: EmbindString): Data | null;

Returns the dataset with the given name, or null if not found.

Parameters

ParameterType
nameEmbindString

Returns

Data | null


getImage()

ts
getImage(kind?: DataKind, modality?: DataModality): SharedImageSet | null;

Returns the first SharedImageSet matching the given kind and modality. DataKind "UNKNOWN" matches all kinds and DataModality "NA" matches all modalities.

Parameters

ParameterType
kind?DataKind
modality?DataModality

Returns

SharedImageSet | null


getImages()

ts
getImages(kind?: DataKind, modality?: DataModality): HandleArray<SharedImageSet>;

Returns all SharedImageSets matching the given kind and modality. DataKind "UNKNOWN" matches all kinds and DataModality "NA" matches all modalities.

Parameters

ParameterType
kind?DataKind
modality?DataModality

Returns

HandleArray<SharedImageSet>


add()

ts
add(data: Data | null): boolean;

Adds a dataset to the data model. The model takes shared ownership of the dataset until it is removed via remove() or clear().

Parameters

ParameterType
dataData | null

Returns

boolean

True if the dataset was added successfully.


remove()

ts
remove(data: Data | null): boolean;

Removes the given dataset from the DataModel.

Parameters

ParameterType
dataData | null

Returns

boolean

True if the dataset was removed successfully.


clear()

ts
clear(): void;

Removes all datasets from the DataModel.

Returns

void


onDataAdded()

ts
onDataAdded(callback: (data: Data) => void): () => void;

Fires when a dataset is added.

Parameters

ParameterTypeDescription
callback(data: Data) => voidCalled with the added data.

Returns

Unsubscribe function.

() => void


onDataAboutToBeRemoved()

ts
onDataAboutToBeRemoved(callback: (data: Data) => void): () => void;

Fires directly before a dataset is removed.

Parameters

ParameterTypeDescription
callback(data: Data) => voidCalled with the data about to be removed.

Returns

Unsubscribe function.

() => void

On this page