mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 23:56:51 +00:00
🔥 Nuke all mcschema related code
This commit is contained in:
@@ -5,6 +5,5 @@ export * from './useFocus.js'
|
||||
export * from './useHash.js'
|
||||
export * from './useLocalStorage.js'
|
||||
export * from './useMediaQuery.js'
|
||||
export * from './useModel.js'
|
||||
export * from './useSearchParam.js'
|
||||
export * from './useTags.js'
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import type { DataModel } from '@mcschema/core'
|
||||
import type { Inputs } from 'preact/hooks'
|
||||
import { useEffect } from 'preact/hooks'
|
||||
|
||||
export function useModel(model: DataModel | undefined | null, invalidated: (model: DataModel) => unknown, inputs?: Inputs) {
|
||||
const listener = {
|
||||
invalidated() {
|
||||
if (model) {
|
||||
invalidated(model)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
model?.addListener(listener)
|
||||
return () => {
|
||||
model?.removeListener(listener)
|
||||
}
|
||||
}, [model, ...inputs ?? []])
|
||||
}
|
||||
Reference in New Issue
Block a user