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

Function derived

packages/svelte/src/internal/client/reactivity/deriveds.js:71–101  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

69 */
70/*#__NO_SIDE_EFFECTS__*/
71export function derived(fn) {
72 var flags = DERIVED | DIRTY;
73
74 if (active_effect !== null) {
75 // Since deriveds are evaluated lazily, any effects created inside them are
76 // created too late to ensure that the parent effect is added to the tree
77 active_effect.f |= EFFECT_PRESERVED;
78 }
79
80 /** @type {Derived<V>} */
81 const signal = {
82 ctx: component_context,
83 deps: null,
84 effects: null,
85 equals,
86 f: flags,
87 fn,
88 reactions: null,
89 rv: 0,
90 v: /** @type {V} */ (UNINITIALIZED),
91 wv: 0,
92 parent: active_effect,
93 ac: null
94 };
95
96 if (DEV && tracing_mode_flag) {
97 signal.created = get_error('created at');
98 }
99
100 return signal;
101}
102
103export const OBSOLETE = Symbol('obsolete');
104

Callers 8

date.test.tsFile · 0.90
initFunction · 0.90
get_fallbackFunction · 0.90
test.tsFile · 0.90
readFunction · 0.90
create_derivedFunction · 0.90
user_derivedFunction · 0.70
derived_safe_equalFunction · 0.70

Calls 1

get_errorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…