Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions force-app/lwc/signals/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,16 @@ function $resource(fn, source, options) {
error: null
};
} catch (error) {
_signal.value = onError(error, _value, { identifier, initialValue }) ?? {
data: null,
loading: false,
error
};
const errorValue = onError(error, _value, { identifier, initialValue });
if (errorValue) {
_signal.value = errorValue;
} else {
_signal.value = {
data: null,
loading: false,
error
};
}
} finally {
_isInitialLoad = false;
}
Expand Down
11 changes: 6 additions & 5 deletions src/lwc/signals/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,10 @@ function isSignal(anything: unknown): anything is Signal<unknown> {
);
}

class Binder {
class Binder<Element extends HTMLElement> {
constructor(
private component: Record<string, object>,
private propertyName: string
private component: Element,
private propertyName: keyof Element,
) {}

to<T>(signal: Signal<T>) {
Expand All @@ -615,8 +615,8 @@ class Binder {
}
}

function bind(component: Record<string, object>, propertyName: string) {
return new Binder(component, propertyName);
function bind<T extends HTMLElement>(component: T, propertyName: keyof T) {
return new Binder<T>(component, propertyName);
}

export {
Expand All @@ -628,3 +628,4 @@ export {
bind as $bind,
isSignal
};