pull/10798/head
Rich Harris 2 years ago
parent 683abe0e7b
commit fd182df8b1

@ -597,8 +597,7 @@ function create_block(item, key, index, render_fn, flags) {
};
block.e = render_effect(
/** @param {import('#client').EachItemBlock} block */
(block) => {
() => {
render_fn(null, block.v, block.i);
},
block,

@ -28,7 +28,7 @@ import { noop } from '../../common.js';
/**
* @param {import('./types.js').EffectType} type
* @param {(() => void | (() => void)) | ((b: import('#client').Block) => void | (() => void))} fn
* @param {(() => void | (() => void))} fn
* @param {boolean} sync
* @param {null | import('#client').Block} block
* @param {boolean} init
@ -216,8 +216,7 @@ export function invalidate_effect(fn) {
}
/**
* @template {import('#client').Block} B
* @param {(block: B) => void | (() => void)} fn
* @param {(() => void)} fn
* @param {any} block
* @param {any} managed
* @param {any} sync
@ -249,6 +248,7 @@ export function destroy_effect(effect) {
effect.teardown?.();
effect.ondestroy?.();
// @ts-expect-error
effect.fn =
effect.effects =
effect.teardown =

@ -21,7 +21,7 @@ export interface Value<V = unknown> extends Signal {
export interface Reaction extends Signal {
/** The reaction function */
fn: null | Function;
fn: Function;
/** Signals that this signal reads from */
deps: null | Value[];
/** Effects created inside this signal */
@ -44,7 +44,7 @@ export interface Effect extends Reaction {
/** Stuff to do when the effect is destroyed */
ondestroy: null | (() => void);
/** The effect function */
fn: null | (() => void | (() => void)) | ((b: Block, s: Signal) => void | (() => void));
fn: () => void | (() => void);
/** The teardown function returned from the effect function */
teardown: null | (() => void);
/** The depth from the root signal, used for ordering render/pre-effects topologically **/

@ -215,7 +215,6 @@ export function check_dirtiness(reaction) {
export function execute_reaction_fn(signal) {
const fn = signal.fn;
const flags = signal.f;
const is_render_effect = (flags & RENDER_EFFECT) !== 0;
const previous_dependencies = current_dependencies;
const previous_dependencies_index = current_dependencies_index;
@ -232,19 +231,7 @@ export function execute_reaction_fn(signal) {
current_untracking = false;
try {
let res;
if (is_render_effect) {
res = /** @type {(block: import('#client').Block, signal: import('#client').Signal) => V} */ (
fn
)(
/** @type {import('#client').Block} */ (
/** @type {import('#client').Effect} */ (signal).block
),
/** @type {import('#client').Signal} */ (signal)
);
} else {
res = /** @type {() => V} */ (fn)();
}
let res = fn();
let dependencies = /** @type {import('./types.js').Value<unknown>[]} **/ (signal.deps);
if (current_dependencies !== null) {
let i;

Loading…
Cancel
Save