Skip to content

Commit

Permalink
refactor(core): remove signal mutate implementation (angular#52348)
Browse files Browse the repository at this point in the history
It's not used anymore.

PR Close angular#52348
  • Loading branch information
JeanMeche authored and rlmestre committed Jan 26, 2024
1 parent 37a9cad commit 84b4c4e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 14 deletions.
3 changes: 0 additions & 3 deletions goldens/public-api/core/primitives/signals/index.md
Expand Up @@ -104,9 +104,6 @@ export interface SignalGetter<T> extends SignalBaseGetter<T> {
readonly [SIGNAL]: SignalNode<T>;
}

// @public (undocumented)
export function signalMutateFn<T>(node: SignalNode<T>, mutator: (value: T) => void): void;

// @public (undocumented)
export interface SignalNode<T> extends ReactiveNode {
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/primitives/signals/index.ts
Expand Up @@ -10,6 +10,6 @@ export {createComputed} from './src/computed';
export {defaultEquals, ValueEqualityFn} from './src/equality';
export {setThrowInvalidWriteToSignalError} from './src/errors';
export {consumerAfterComputation, consumerBeforeComputation, consumerDestroy, consumerPollProducersForChange, getActiveConsumer, isInNotificationPhase, isReactive, producerAccessed, producerNotifyConsumers, producerUpdatesAllowed, producerUpdateValueVersion, Reactive, REACTIVE_NODE, ReactiveNode, setActiveConsumer, SIGNAL} from './src/graph';
export {createSignal, setPostSignalSetFn, SIGNAL_NODE, SignalGetter, signalMutateFn, SignalNode, signalSetFn, signalUpdateFn} from './src/signal';
export {createSignal, setPostSignalSetFn, SIGNAL_NODE, SignalGetter, SignalNode, signalSetFn, signalUpdateFn} from './src/signal';
export {createWatch, Watch, WatchCleanupFn, WatchCleanupRegisterFn} from './src/watch';
export {setAlternateWeakRefImpl} from './src/weak_ref';
9 changes: 0 additions & 9 deletions packages/core/primitives/signals/src/signal.ts
Expand Up @@ -79,15 +79,6 @@ export function signalUpdateFn<T>(node: SignalNode<T>, updater: (value: T) => T)
signalSetFn(node, updater(node.value));
}

export function signalMutateFn<T>(node: SignalNode<T>, mutator: (value: T) => void): void {
if (!producerUpdatesAllowed()) {
throwInvalidWriteToSignalError();
}
// Mutate bypasses equality checks as it's by definition changing the value.
mutator(node.value);
signalValueChanged(node);
}

// Note: Using an IIFE here to ensure that the spread assignment is not considered
// a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
// TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/render3/reactivity/signal.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {createSignal, SIGNAL, SignalGetter, signalMutateFn, SignalNode, signalSetFn, signalUpdateFn} from '@angular/core/primitives/signals';
import {createSignal, SIGNAL, SignalGetter, SignalNode, signalSetFn, signalUpdateFn} from '@angular/core/primitives/signals';

import {Signal, ValueEqualityFn} from './api';

Expand Down

0 comments on commit 84b4c4e

Please sign in to comment.