Skip to content
Closed
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
28 changes: 24 additions & 4 deletions goldens/public-api/core/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,24 @@ export interface ContentChildFunction {
<LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: {
descendants?: boolean;
read?: undefined;
debugName?: string;
}): Signal<LocatorT | undefined>;
// (undocumented)
<LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: {
descendants?: boolean;
read: ProviderToken<ReadT>;
debugName?: string;
}): Signal<ReadT | undefined>;
required: {
<LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: {
descendants?: boolean;
read?: undefined;
debugName?: string;
}): Signal<LocatorT>;
<LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: {
descendants?: boolean;
read: ProviderToken<ReadT>;
debugName?: string;
}): Signal<ReadT>;
};
}
Expand All @@ -410,12 +414,14 @@ export const ContentChildren: ContentChildrenDecorator;
export function contentChildren<LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: {
descendants?: boolean;
read?: undefined;
debugName?: string;
}): Signal<ReadonlyArray<LocatorT>>;

// @public (undocumented)
export function contentChildren<LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: {
descendants?: boolean;
read: ProviderToken<ReadT>;
debugName?: string;
}): Signal<ReadonlyArray<ReadT>>;

// @public
Expand Down Expand Up @@ -443,13 +449,15 @@ export function createComponent<C>(component: Type<C>, options: {

// @public
export interface CreateComputedOptions<T> {
debugName?: string;
equal?: ValueEqualityFn<T>;
}

// @public
export interface CreateEffectOptions {
// @deprecated (undocumented)
allowSignalWrites?: boolean;
debugName?: string;
forceRoot?: true;
injector?: Injector;
manualCleanup?: boolean;
Expand All @@ -472,6 +480,7 @@ export function createPlatformFactory(parentPlatformFactory: ((extraProviders?:

// @public
export interface CreateSignalOptions<T> {
debugName?: string;
equal?: ValueEqualityFn<T>;
}

Expand Down Expand Up @@ -993,6 +1002,7 @@ export interface InputFunction {
// @public
export interface InputOptions<T, TransformT> {
alias?: string;
debugName?: string;
transform?: (v: TransformT) => T;
}

Expand Down Expand Up @@ -1151,6 +1161,7 @@ export interface ModelFunction {
// @public
export interface ModelOptions {
alias?: string;
debugName?: string;
}

// @public
Expand Down Expand Up @@ -1778,15 +1789,21 @@ export interface ViewChildDecorator {

// @public
export interface ViewChildFunction {
<LocatorT>(locator: ProviderToken<LocatorT> | string): Signal<LocatorT | undefined>;
// (undocumented)
<LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: {
read: ProviderToken<ReadT>;
debugName?: string;
}): Signal<ReadT | undefined>;
// (undocumented)
<LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: {
debugName?: string;
}): Signal<LocatorT | undefined>;
required: {
<LocatorT>(locator: ProviderToken<LocatorT> | string): Signal<LocatorT>;
<LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: {
debugName?: string;
}): Signal<LocatorT>;
<LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: {
read: ProviderToken<ReadT>;
debugName?: string;
}): Signal<ReadT>;
};
}
Expand All @@ -1798,11 +1815,14 @@ export type ViewChildren = Query;
export const ViewChildren: ViewChildrenDecorator;

// @public (undocumented)
export function viewChildren<LocatorT>(locator: ProviderToken<LocatorT> | string): Signal<ReadonlyArray<LocatorT>>;
export function viewChildren<LocatorT>(locator: ProviderToken<LocatorT> | string, opts?: {
debugName?: string;
}): Signal<ReadonlyArray<LocatorT>>;

// @public (undocumented)
export function viewChildren<LocatorT, ReadT>(locator: ProviderToken<LocatorT> | string, opts: {
read: ProviderToken<ReadT>;
debugName?: string;
}): Signal<ReadonlyArray<ReadT>>;

// @public
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/authoring/input/input_signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export interface InputOptions<T, TransformT> {
* handle such string values and convert them to `boolean`. See: {@link booleanAttribute}.
*/
transform?: (v: TransformT) => T;

/**
* A debug name for the input signal. Used in Angular DevTools to identify the signal.
*/
debugName?: string;
}

/**
Expand Down Expand Up @@ -135,6 +140,7 @@ export function createInputSignal<T, TransformT>(

if (ngDevMode) {
inputValueFn.toString = () => `[Input Signal: ${inputValueFn()}]`;
node.debugName = options?.debugName;
}

return inputValueFn as InputSignalWithTransform<T, TransformT>;
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/authoring/input/input_signal_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export interface InputSignalNode<T, TransformT> extends SignalNode<T> {
* purposes we assume it's a valid `T` value. Type-checking will enforce that.
*/
applyValueToInputSignal<T, TransformT>(node: InputSignalNode<T, TransformT>, value: T): void;

/**
* A debug name for the input signal. Used in Angular DevTools to identify the signal.
*/
debugName?: string;
}

// Note: Using an IIFE here to ensure that the spread assignment is not considered
Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/authoring/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ import {REQUIRED_UNSET_VALUE} from '../input/input_signal_node';

import {createModelSignal, ModelOptions, ModelSignal} from './model_signal';

export function modelFunction<T>(initialValue?: T): ModelSignal<T | undefined> {
export function modelFunction<T>(
initialValue?: T,
opts?: ModelOptions,
): ModelSignal<T | undefined> {
ngDevMode && assertInInjectionContext(model);

return createModelSignal(initialValue);
return createModelSignal(initialValue, opts);
}

export function modelRequiredFunction<T>(): ModelSignal<T> {
export function modelRequiredFunction<T>(opts?: ModelOptions): ModelSignal<T> {
ngDevMode && assertInInjectionContext(model);

return createModelSignal(REQUIRED_UNSET_VALUE as T);
return createModelSignal(REQUIRED_UNSET_VALUE as T, opts);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/authoring/model/model_signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export interface ModelOptions {
* name as the input, but suffixed with `Change`. By default, the class field name is used.
*/
alias?: string;

/**
* A debug name for the model signal. Used in Angular DevTools to identify the signal.
*/
debugName?: string;
}

/**
Expand All @@ -56,7 +61,7 @@ export interface ModelSignal<T> extends WritableSignal<T>, InputSignal<T>, Outpu
* Can be set to {@link REQUIRED_UNSET_VALUE} for required model signals.
* @param options Additional options for the model.
*/
export function createModelSignal<T>(initialValue: T): ModelSignal<T> {
export function createModelSignal<T>(initialValue: T, opts?: ModelOptions): ModelSignal<T> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ModelOptions's alias isn't used in the function. Should we narrow down the type here ?

const node: InputSignalNode<T, T> = Object.create(INPUT_SIGNAL_NODE);
const emitterRef = new OutputEmitterRef<T>();

Expand Down Expand Up @@ -89,6 +94,7 @@ export function createModelSignal<T>(initialValue: T): ModelSignal<T> {

if (ngDevMode) {
getter.toString = () => `[Model Signal: ${getter()}]`;
node.debugName = opts?.debugName;
}

return getter as typeof getter &
Expand Down
Loading