Skip to content

Commit b30bcc5

Browse files
tsc036thePunderWoman
authored andcommitted
refactor(core): export types from primitives
export Version type and a type for linkedSignal previous value so they can be used for the Wiz implementations (cherry picked from commit 104f7d5)
1 parent d8c656b commit b30bcc5

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

goldens/public-api/core/primitives/signals/index.api.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export interface BaseEffectNode extends ReactiveNode {
2020
}
2121

2222
// @public (undocumented)
23-
export type ComputationFn<S, D> = (source: S, previous?: {
24-
source: S;
25-
value: D;
26-
}) => D;
23+
export type ComputationFn<S, D> = (source: S, previous?: PreviousValue<S, D>) => D;
2724

2825
// @public
2926
export interface ComputedNode<T> extends ReactiveNode {
@@ -101,6 +98,12 @@ export function linkedSignalSetFn<S, D>(node: LinkedSignalNode<S, D>, newValue:
10198
// @public (undocumented)
10299
export function linkedSignalUpdateFn<S, D>(node: LinkedSignalNode<S, D>, updater: (value: D) => D): void;
103100

101+
// @public (undocumented)
102+
export type PreviousValue<S, D> = {
103+
source: S;
104+
value: D;
105+
};
106+
104107
// @public
105108
export function producerAccessed(node: ReactiveNode): void;
106109

@@ -220,6 +223,11 @@ export function untracked<T>(nonReactiveReadsFn: () => T): T;
220223
// @public
221224
export type ValueEqualityFn<T> = (a: T, b: T) => boolean;
222225

226+
// @public (undocumented)
227+
export type Version = number & {
228+
__brand: 'Version';
229+
};
230+
223231
// @public (undocumented)
224232
export interface Watch {
225233
// (undocumented)

packages/core/primitives/signals/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
ComputationFn,
1414
LinkedSignalNode,
1515
LinkedSignalGetter,
16+
PreviousValue,
1617
createLinkedSignal,
1718
linkedSignalSetFn,
1819
linkedSignalUpdateFn,
@@ -45,6 +46,7 @@ export {
4546
runPostProducerCreatedFn,
4647
setActiveConsumer,
4748
setPostProducerCreatedFn,
49+
Version,
4850
} from './src/graph';
4951
export {
5052
SIGNAL_NODE,

packages/core/primitives/signals/src/graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare const ngDevMode: boolean | undefined;
1818
let activeConsumer: ReactiveNode | null = null;
1919
let inNotificationPhase = false;
2020

21-
type Version = number & {__brand: 'Version'};
21+
export type Version = number & {__brand: 'Version'};
2222

2323
/**
2424
* Global epoch counter. Incremented whenever a source signal is set.

packages/core/primitives/signals/src/linked_signal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import {signalSetFn, signalUpdateFn} from './signal';
2525
// global `ngDevMode` type is defined.
2626
declare const ngDevMode: boolean | undefined;
2727

28-
export type ComputationFn<S, D> = (source: S, previous?: {source: S; value: D}) => D;
28+
export type ComputationFn<S, D> = (source: S, previous?: PreviousValue<S, D>) => D;
29+
export type PreviousValue<S, D> = {source: S; value: D};
2930

3031
export interface LinkedSignalNode<S, D> extends ReactiveNode {
3132
/**

0 commit comments

Comments
 (0)