(fn)
| 69 | */ |
| 70 | /*#__NO_SIDE_EFFECTS__*/ |
| 71 | export 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 | |
| 103 | export const OBSOLETE = Symbol('obsolete'); |
| 104 |
no test coverage detected
searching dependent graphs…