Skip to content

Class: TileLoader

tile-loader.TileLoader

A TileLoader extends DataLoader to provide batching and caching functionalities for loading TileDocument streams.

It is exported by the tile-loader module.

import { TileLoader } from '@glazed/tile-loader'

Hierarchy

  • DataLoader<TileKey, TileDocument>

TileLoader

Constructors

constructor

new TileLoader(params)

Parameters

Name Type
params TileLoaderParams

Overrides

DataLoader<TileKey, TileDocument\>.constructor

Methods

cache

cache(stream): boolean

Add a TileDocument to the local cache, if enabled.

Parameters

Name Type
stream TileDocument<Record<string, any>>

Returns

boolean


create

create<T>(content, metadata?, options?): Promise<TileDocument<T>>

Create a new TileDocument and add it to the cache, if enabled.

Type parameters

Name Type
T extends Record<string, any> = Record<string, any>

Parameters

Name Type
content T
metadata? TileMetadataArgs
options? CreateOpts

Returns

Promise<TileDocument<T>>


deterministic

deterministic<T>(metadata, options?): Promise<TileDocument<undefined | null | T>>

Create or load a deterministic TileDocument based on its metadata.

Type parameters

Name Type
T extends Record<string, any> = Record<string, any>

Parameters

Name Type
metadata TileMetadataArgs
options? CreateOpts

Returns

Promise<TileDocument<undefined | null | T>>


load

load<T>(key): Promise<TileDocument<T>>

Load a TileDocument from the cache (if enabled) or remotely.

Type parameters

Name Type
T extends Record<string, any> = Record<string, any>

Parameters

Name Type
key TileKey

Returns

Promise<TileDocument<T>>

Overrides

DataLoader.load


update

update<T>(streamID, content?, metadata?, options?): Promise<TileDocument<undefined | null | T>>

Update a TileDocument after loading the stream remotely, bypassing the cache.

Type parameters

Name Type
T extends Record<string, any> = Record<string, any>

Parameters

Name Type
streamID string | StreamID
content? T
metadata? TileMetadataArgs
options? UpdateOpts

Returns

Promise<TileDocument<undefined | null | T>>