Merge pull request #249 from bipproduction/amalia/21-september-24

upd: realtime
This commit is contained in:
Amalia
2024-09-21 15:54:58 +08:00
committed by GitHub
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>
)
}

11
src/app/test/page.tsx Normal file
View File

@@ -0,0 +1,11 @@
import { Stack } from "@mantine/core";
import { RealtimePage } from "./_ui/RealtimePage";
const WIBU_REALTIME_KEY = process.env.WIBU_REALTIME_KEY!
export default function Page() {
return (
<Stack>
<RealtimePage wibuKey={WIBU_REALTIME_KEY} />
</Stack>
)
}