File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -72,16 +72,11 @@ Business logic and pure utilities belong outside `<script>` blocks — in the ne
7272Extract business logic as pure functions to ` utils/ ` (or ` _utils/ ` for routes); keep side effects in the caller:
7373
7474``` typescript
75- // Before: untestable — mixes URL construction (pure logic) with replaceState() (side effect)
76- function updateUrl() {
77- const url = new URL ($page .url );
78- url .searchParams .set (' tab' , activeTab );
79- replaceState (url , {});
80- }
81-
82- // After: pure function in _utils/, side effect in caller
75+ // Pure function in _utils/ — testable, no side effects
8376export function buildUpdatedUrl(url : URL , activeTab : ActiveTab ): URL { ... }
84- // Caller: replaceState(buildUpdatedUrl($page.url, activeTab), {})
77+
78+ // Side effect stays in the caller
79+ replaceState (buildUpdatedUrl ($page .url , activeTab ), {});
8580```
8681
8782## Empty-list Fallback in ` {#each} `
You can’t perform that action at this time.
0 commit comments