Skip to content

Commit 7aa3c0b

Browse files
committed
feat(types): fixing types for select::json.
1 parent 4979d57 commit 7aa3c0b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveltekit-sse",
3-
"version": "0.13.13",
3+
"version": "0.13.14",
44
"scripts": {
55
"dev": "vite dev",
66
"build": "vite build",

src/lib/types.external.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export {}
127127
*/
128128

129129
/**
130-
* @typedef {<T>(or?:import('./types.external').JsonPredicate<T>)=>import('svelte/store').Readable<T>} Jsonifier
130+
* @typedef {<T = null>(or?:import('./types.external').JsonPredicate<T>)=>import('svelte/store').Readable<T extends null ? T|undefined : T>} Jsonifier
131131
*/
132132

133133
/**

src/routes/issue-65/+page.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<script>
22
import { source } from '$lib'
33
4-
const connection = source('/issue-65/events')
5-
const stats = connection.select('message').json()
4+
const connection = source('/events')
5+
const stats = connection.select('message').json(function or() {
6+
return { cpu_usage: '0.00%', memory: '0.00 MB', time: 0 }
7+
})
68
</script>
79

810
<main>
911
<h2>Admin dashboard page</h2>
1012

11-
{#if $stats}
12-
<span>Cpu usage - {$stats.cpu_usage}</span><br />
13-
<span>Memory - {$stats.memory}</span><br />
14-
<span>Time - {$stats.time}</span><br />
15-
{/if}
13+
<span>Cpu usage - {$stats.cpu_usage}</span><br />
14+
<span>Memory - {$stats.memory}</span><br />
15+
<span>Time - {$stats.time}</span><br />
1616
</main>

0 commit comments

Comments
 (0)