Skip to content
Open
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
8 changes: 1 addition & 7 deletions src/aria/private/behaviors/signal-like/signal-like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,17 @@ export function convertGetterSetterToWritableSignalLike<T>(
}

export function computed<T>(computation: () => T): SignalLike<T> {
const computed = createComputed(computation);
// TODO: Remove the `toString` after https://github.com/angular/angular/pull/65948 is merged.
computed.toString = () => `[Computed: ${computed()}]`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the toString because the linked issue has been merged, but I realized this isn't identical; computed() picks up a reactive dependency whereas the primitives' toString() implementation would not.

Depending on how angular/angular#67511 gets resolved this may need to change here as well, as I think it's beneficial to keep this behavior identical to Angular's primary signal behaviors.

computed[SIGNAL].debugName = '';
return computed;
return createComputed(computation);
}

export function signal<T>(initialValue: T): WritableSignalLike<T> {
const [get, set, update] = createSignal(initialValue);
get[SIGNAL].debugName = '';
// tslint:disable-next-line:ban Have to use `Object.assign` to preserve the getter function.
return Object.assign(get, {set, update, asReadonly: () => get});
}

export function linkedSignal<T>(sourceFn: () => T): WritableSignalLike<T> {
const getter = createLinkedSignal(sourceFn, s => s);
getter[SIGNAL].debugName = '';
// tslint:disable-next-line:ban Have to use `Object.assign` to preserve the getter function.
return Object.assign(getter, {
set: (v: T) => linkedSignalSetFn(getter[SIGNAL], v),
Expand Down
Loading