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

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

@ -31,7 +31,7 @@ export function source(value) {
/** @type {import('#client').Source<V>} */ /** @type {import('#client').Source<V>} */
const source = { const source = {
reactions: null, reactions: null,
e: default_equals, eq: default_equals,
f: SOURCE | CLEAN, f: SOURCE | CLEAN,
v: value, v: value,
w: 0 w: 0
@ -52,7 +52,7 @@ export function source(value) {
/*#__NO_SIDE_EFFECTS__*/ /*#__NO_SIDE_EFFECTS__*/
export function mutable_source(initial_value) { export function mutable_source(initial_value) {
const s = 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 // bind the signal to the component context, in case we need to
// track updates to trigger beforeUpdate/afterUpdate callbacks // track updates to trigger beforeUpdate/afterUpdate callbacks
@ -111,7 +111,7 @@ export function set(signal, value) {
} }
if ( if (
(signal.f & SOURCE) !== 0 && (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; signal.v = value;
// Increment write version so that unowned signals can properly track dirtyness // 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> { export interface Source<V = unknown> {
/** Signals that read from this signal */ /** Signals that read from this signal */
reactions: null | Reaction[]; reactions: null | Reaction[];
/** equals: For value equality */ /** Equality function */
e: null | EqualsFunctions; eq: EqualsFunctions;
/** flags: The types that the signal represent, as a bitwise value */ /** flags: The types that the signal represent, as a bitwise value */
f: SignalFlags; f: SignalFlags;
/** value: The latest value for this signal */ /** value: The latest value for this signal */
@ -55,8 +55,6 @@ export type Effect = {
d: null | Value[]; d: null | Value[];
/** destroy: Thing(s) that need destroying */ /** destroy: Thing(s) that need destroying */
y: null | (() => void); y: null | (() => void);
/** equals: For value equality */
e: null | EqualsFunctions;
/** The types that the signal represent, as a bitwise value */ /** The types that the signal represent, as a bitwise value */
f: SignalFlags; f: SignalFlags;
/** init: The function that we invoke for effects and computeds */ /** 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); 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) { return function (/** @type {V} */ value, mutation = false) {
var current = get(current_value); var current = get(current_value);

@ -693,7 +693,7 @@ function update_derived(signal, force_schedule) {
? MAYBE_DIRTY ? MAYBE_DIRTY
: CLEAN; : CLEAN;
set_signal_status(signal, status); 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)) { if (!equals(value, signal.v)) {
signal.v = value; signal.v = value;
mark_reactions(signal, DIRTY, force_schedule); mark_reactions(signal, DIRTY, force_schedule);

Loading…
Cancel
Save