refactor: 🏗️
This commit is contained in:
parent
d964c7b7b3
commit
e25902b8b4
18 changed files with 619 additions and 426 deletions
16
src/hooks/useThread.tsx
Normal file
16
src/hooks/useThread.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import threadService from '@/services/thread.service'
|
||||
import { useSyncExternalStore } from 'react'
|
||||
|
||||
export function useThread(stuffKey: string) {
|
||||
return useSyncExternalStore(
|
||||
(cb) => threadService.listenThread(stuffKey, cb),
|
||||
() => threadService.getThread(stuffKey)
|
||||
)
|
||||
}
|
||||
|
||||
export function useAllDescendantThreads(stuffKey: string) {
|
||||
return useSyncExternalStore(
|
||||
(cb) => threadService.listenAllDescendantThreads(stuffKey, cb),
|
||||
() => threadService.getAllDescendantThreads(stuffKey)
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue