MCPcopy
hub / github.com/sveltejs/svelte / handler

Function handler

packages/svelte/src/internal/client/reactivity/deriveds.js:211–248  ·  view source on GitHub ↗
(value, error = undefined)

Source from the content-addressed store, hash-verified

209 * @param {unknown} error
210 */
211 const handler = (value, error = undefined) => {
212 if (DEV) {
213 reactivity_loss_tracker = null;
214 }
215
216 decrement_pending?.();
217 deferreds.delete(d);
218
219 if (error === OBSOLETE) return;
220
221 batch.activate();
222
223 if (error) {
224 signal.f |= ERROR_VALUE;
225
226 // @ts-expect-error the error is the wrong type, but we don't care
227 internal_set(signal, error);
228 } else {
229 if ((signal.f & ERROR_VALUE) !== 0) {
230 signal.f ^= ERROR_VALUE;
231 }
232
233 if (DEV && location !== undefined && !signal.equals(value)) {
234 recent_async_deriveds.add(signal);
235
236 setTimeout(() => {
237 if (recent_async_deriveds.has(signal) && (effect.f & DESTROYED) === 0) {
238 w.await_waterfall(/** @type {string} */ (signal.label), location);
239 recent_async_deriveds.delete(signal);
240 }
241 });
242 }
243
244 internal_set(signal, value);
245 }
246
247 batch.deactivate();
248 };
249
250 d.promise.then(handler, (e) => handler(null, e || 'unknown'));
251 });

Callers 2

async_derivedFunction · 0.70
bundleFunction · 0.50

Calls 6

internal_setFunction · 0.90
activateMethod · 0.80
deactivateMethod · 0.80
deleteMethod · 0.45
addMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected