Skip to content

Commit 895e048

Browse files
committed
use once
1 parent dadff16 commit 895e048

File tree

1 file changed

+2
-1
lines changed
  • packages/svelte/src/internal/server

1 file changed

+2
-1
lines changed

packages/svelte/src/internal/server/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,15 @@ export { escape_html as escape };
521521
* @returns {(new_value?: T) => (T | void)}
522522
*/
523523
export function derived(fn) {
524+
const get_value = once(fn);
524525
/**
525526
* @type {T | undefined}
526527
*/
527528
let updated_value;
528529

529530
return function (new_value) {
530531
if (arguments.length === 0) {
531-
return updated_value ?? fn();
532+
return updated_value ?? get_value();
532533
}
533534
updated_value = new_value;
534535
return updated_value;

0 commit comments

Comments
 (0)