Skip to content

Commit

Permalink
fix(core): adjust onLoad parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Aug 15, 2024
1 parent b1d1006 commit fd37f28
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libs/core/src/lib/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function load<
TData,
TUrl extends string | string[] | Record<string, string>,
TLoaderConstructor extends NgtLoaderProto<TData>,
TReturn = NgtLoaderReturnType<TData, TLoaderConstructor>,
>(
loaderConstructorFactory: (inputs: string[]) => TLoaderConstructor,
inputs: () => TUrl,
Expand All @@ -53,7 +54,7 @@ function load<
onProgress,
}: {
extensions?: NgtLoaderExtensions<TLoaderConstructor>;
onLoad?: (data: TData) => void;
onLoad?: (data: NoInfer<TReturn>) => void;
onProgress?: (event: ProgressEvent) => void;
} = {},
) {
Expand Down Expand Up @@ -83,7 +84,7 @@ function load<
}

if (onLoad) {
onLoad(data);
onLoad(data as unknown as TReturn);
}

resolve(data);
Expand Down Expand Up @@ -115,7 +116,7 @@ function _injectLoader<
}: {
extensions?: NgtLoaderExtensions<TLoaderConstructor>;
onProgress?: (event: ProgressEvent) => void;
onLoad?: (data: NoInfer<TData>) => void;
onLoad?: (data: NoInfer<TReturn>) => void;
injector?: Injector;
} = {},
): Signal<NgtLoaderResults<TUrl, NgtBranchingReturn<TReturn, NgtGLTFLike, NgtGLTFLike & NgtObjectMap>> | null> {
Expand All @@ -127,7 +128,11 @@ function _injectLoader<
> | null>(null);

afterNextRender(() => {
const effector = load(loaderConstructorFactory, inputs, { extensions, onProgress, onLoad });
const effector = load(loaderConstructorFactory, inputs, {
extensions,
onProgress,
onLoad: onLoad as (data: unknown) => void,
});
autoEffect(
() => {
const originalUrls = inputs();
Expand Down

0 comments on commit fd37f28

Please sign in to comment.