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