more clarity

pull/10760/head
Rich Harris 3 years ago
parent 4a6a8c6433
commit bcaea0af44

@ -26,7 +26,7 @@ export function derived(fn) {
b: current_block,
reactions: null,
d: null,
e: default_equals,
eq: default_equals,
f: flags,
i: fn,
r: null,
@ -56,7 +56,7 @@ export function derived(fn) {
/*#__NO_SIDE_EFFECTS__*/
export function derived_safe_equal(fn) {
const signal = derived(fn);
signal.e = safe_equal;
signal.eq = safe_equal;
return signal;
}

@ -44,7 +44,6 @@ function create_effect(type, fn, sync, block, schedule) {
const signal = {
b: block,
d: null,
e: null,
f: type | DIRTY,
l: 0,
i: fn,

@ -31,7 +31,7 @@ export function source(value) {
/** @type {import('#client').Source<V>} */
const source = {
reactions: null,
e: default_equals,
eq: default_equals,
f: SOURCE | CLEAN,
v: value,
w: 0
@ -52,7 +52,7 @@ export function source(value) {
/*#__NO_SIDE_EFFECTS__*/
export function mutable_source(initial_value) {
const s = source(initial_value);
s.e = safe_equal;
s.eq = safe_equal;
// bind the signal to the component context, in case we need to
// track updates to trigger beforeUpdate/afterUpdate callbacks
@ -111,7 +111,7 @@ export function set(signal, value) {
}
if (
(signal.f & SOURCE) !== 0 &&
!(/** @type {import('#client').EqualsFunctions} */ (signal.e)(value, signal.v))
!(/** @type {import('#client').EqualsFunctions} */ (signal.eq)(value, signal.v))
) {
signal.v = value;
// Increment write version so that unowned signals can properly track dirtyness

@ -12,8 +12,8 @@ export type EffectType = typeof EFFECT | typeof PRE_EFFECT | typeof RENDER_EFFEC
export interface Source<V = unknown> {
/** Signals that read from this signal */
reactions: null | Reaction[];
/** equals: For value equality */
e: null | EqualsFunctions;
/** Equality function */
eq: EqualsFunctions;
/** flags: The types that the signal represent, as a bitwise value */
f: SignalFlags;
/** value: The latest value for this signal */
@ -55,8 +55,6 @@ export type Effect = {
d: null | Value[];
/** destroy: Thing(s) that need destroying */
y: null | (() => void);
/** equals: For value equality */
e: null | EqualsFunctions;
/** The types that the signal represent, as a bitwise value */
f: SignalFlags;
/** init: The function that we invoke for effects and computeds */

@ -2829,7 +2829,7 @@ export function prop(props, key, flags, initial) {
return (inner_current_value.v = parent_value);
});
if (!immutable) current_value.e = safe_equal;
if (!immutable) current_value.eq = safe_equal;
return function (/** @type {V} */ value, mutation = false) {
var current = get(current_value);

@ -693,7 +693,7 @@ function update_derived(signal, force_schedule) {
? MAYBE_DIRTY
: CLEAN;
set_signal_status(signal, status);
const equals = /** @type {import('./types.js').EqualsFunctions} */ (signal.e);
const equals = /** @type {import('./types.js').EqualsFunctions} */ (signal.eq);
if (!equals(value, signal.v)) {
signal.v = value;
mark_reactions(signal, DIRTY, force_schedule);

Loading…
Cancel
Save