Merge pull request #249 from bipproduction/amalia/21-september-24
upd: realtime
This commit is contained in:
27
src/app/test/_ui/RealtimePage.tsx
Normal file
27
src/app/test/_ui/RealtimePage.tsx
Normal 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
11
src/app/test/page.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user