feat: main Attempted rolling own state

This commit is contained in:
Nikolaj Frey 2023-06-30 10:06:07 +10:00
parent 9793237357
commit 16b9c41bbe
3 changed files with 24 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import React from 'react'
import { Box, Flex } from '@chakra-ui/react'
import { Safe } from '../Safety/Safe'
import { useThingtime } from './useThingtime'
export const Thingtime = props => {
// const uuid = React.useMemo(() => {
@ -8,6 +9,12 @@ export const Thingtime = props => {
// }, [])
const uuid = React.useRef(Math.random().toString(36).substring(7))
const { state } = useThingtime()
React.useEffect(() => {
console.log('nik state changed', state)
}, [state])
const depth = React.useMemo(() => {
return props?.depth || 1
}, [props?.depth])

View File

@ -0,0 +1,15 @@
import React from 'react'
const getGlobal = () => {
try {
return window
} catch {
return globalThis
}
}
export const useThingtime = (props?: any) => {
const glob = getGlobal()
return { state: {} }
}

View File

@ -54,6 +54,8 @@ const setThingtime = glob => {
try {
glob.thingtime = {
tmp: {},
subscribers: {},
state: {},
things: {
db: {},
limit: 9999,