MCPcopy
hub / github.com/angular/angular / readonly

Function readonly

packages/forms/signals/src/api/rules/readonly.ts:41–61  ·  view source on GitHub ↗
(
  path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,
  configOrLogic?:
    | {when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>}
    | NoInfer<LogicFn<TValue, boolean, TPathKind>>,
)

Source from the content-addressed store, hash-verified

39): void;
40
41export function readonly<TValue, TPathKind extends PathKind = PathKind.Root>(
42 path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,
43 configOrLogic?:
44 | {when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>}
45 | NoInfer<LogicFn<TValue, boolean, TPathKind>>,
46) {
47 assertPathIsCurrent(path);
48
49 const pathNode = FieldPathNode.unwrapFieldPath(path);
50
51 let logic: LogicFn<TValue, boolean, TPathKind>;
52 if (typeof configOrLogic === 'object' && configOrLogic !== null && 'when' in configOrLogic) {
53 logic = configOrLogic.when ?? (() => true);
54 } else if (typeof configOrLogic === 'function') {
55 logic = configOrLogic;
56 } else {
57 logic = () => true;
58 }
59
60 pathNode.builder.addReadonlyRule(logic);
61}

Callers 5

TestCmpClass · 0.90
TestCmpClass · 0.85
field_node.spec.tsFile · 0.85
submit.spec.tsFile · 0.85
compat.spec.tsFile · 0.85

Calls 3

assertPathIsCurrentFunction · 0.90
unwrapFieldPathMethod · 0.80
addReadonlyRuleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…