upd: realtime

This commit is contained in:
amel
2024-09-21 15:53:53 +08:00
parent 581b416420
commit 61b51fb157
4 changed files with 114 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
'use client'
import { Button, Stack } from '@mantine/core'
import { useShallowEffect } from '@mantine/hooks'
import { useWibuRealtime } from 'wibu-realtime'
export function RealtimePage({ wibuKey }: { wibuKey: string }) {
const [data, setData] = useWibuRealtime({
WIBU_REALTIME_TOKEN: wibuKey,
project: "sdm"
})
useShallowEffect(() => {
if (data) {
console.log(data)
}
}, [data])
async function onTekan() {
setData({
name: Math.random().toString(),
})
}
return (
<Stack p={"lg"}>
{JSON.stringify(data)}
<Button onClick={onTekan}>Tekan</Button>
</Stack>
)
}