Skip to main content

Class: LoaderStrategy<T>

A multi-purpose feature-complete loader strategy supporting multi-piece modules as well as supporting both ECMAScript Modules and CommonJS with reloading support.

Type parameters

NameType
Textends Piece

Implements

Constructors

constructor

โ€ข new LoaderStrategy<T>()

Type parameters

NameType
Textends Piece<PieceOptions, T>

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:21

Properties

clientUsesESModules

โ€ข clientUsesESModules: boolean

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:17


filterDtsFiles

โ€ข Private Readonly filterDtsFiles: boolean = false

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:19


supportedExtensions

โ€ข supportedExtensions: string[]

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:18

Methods

filter

โ–ธ filter(path): FilterResult

Retrieves the name and the extension of the specified file path.

Parameters

NameType
pathstring

Returns

FilterResult

A ModuleData on success, otherwise null to stop the store from processing the path.

Implementation of

ILoaderStrategy.filter

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:36


load

โ–ธ load(store, file): ILoaderResult<T>

The load hook, use this to override the loader.

Parameters

NameType
storeStore<T>
fileModuleData

Returns

ILoaderResult<T>

Implementation of

ILoaderStrategy.load

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:65


onError

โ–ธ onError(error, path): void

Parameters

NameType
errorError
pathstring

Returns

void

Implementation of

ILoaderStrategy.onError

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:104


onLoad

โ–ธ onLoad(): unknown

Called after a piece has been loaded, but before Piece.onLoad and Store.set.

Returns

unknown

Implementation of

ILoaderStrategy.onLoad

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:88


onLoadAll

โ–ธ onLoadAll(): unknown

Called after all pieces have been loaded.

Returns

unknown

Implementation of

ILoaderStrategy.onLoadAll

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:92


onUnload

โ–ธ onUnload(): unknown

Called after a piece has been unloaded or overwritten by a newly loaded piece.

Returns

unknown

Implementation of

ILoaderStrategy.onUnload

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:96


onUnloadAll

โ–ธ onUnloadAll(): unknown

Called after all pieces have been unloaded.

Returns

unknown

Implementation of

ILoaderStrategy.onUnloadAll

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:100


preload

โ–ธ preload(file): AsyncPreloadResult<T>

The pre-load hook, use this to override the loader.

Parameters

NameType
fileModuleData

Returns

AsyncPreloadResult<T>

Implementation of

ILoaderStrategy.preload

Defined in

projects/pieces/src/lib/strategies/LoaderStrategy.ts:51