Function
fromAction
(action, fn = /** @type {() => T} */ (noop))
Source from the content-addressed store, hash-verified
| 94 | * @since 5.32 |
| 95 | */ |
| 96 | export function fromAction(action, fn = /** @type {() => T} */ (noop)) { |
| 97 | return (element) => { |
| 98 | const { update, destroy } = untrack(() => action(element, fn()) ?? {}); |
| 99 | |
| 100 | if (update) { |
| 101 | var ran = false; |
| 102 | render_effect(() => { |
| 103 | const arg = fn(); |
| 104 | if (ran) update(arg); |
| 105 | }); |
| 106 | ran = true; |
| 107 | } |
| 108 | |
| 109 | if (destroy) { |
| 110 | teardown(destroy); |
| 111 | } |
| 112 | }; |
| 113 | } |
Callers
nothing calls this directly
Tested by
no test coverage detected