feat: nds render system
This commit is contained in:
18
app/composables/useUpdate.ts
Normal file
18
app/composables/useUpdate.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export type UpdateCallback = (deltaTime: number, realFrameTime: number) => void;
|
||||
|
||||
export const useUpdate = (callback: UpdateCallback) => {
|
||||
const registerUpdateCallback = inject<
|
||||
(callback: UpdateCallback) => () => void
|
||||
>("registerUpdateCallback");
|
||||
|
||||
onMounted(() => {
|
||||
if (!registerUpdateCallback) {
|
||||
throw new Error(
|
||||
"Missing registerUpdateCallback - useUpdate must be used within a Screen component",
|
||||
);
|
||||
}
|
||||
|
||||
const unregister = registerUpdateCallback(callback);
|
||||
onUnmounted(unregister);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user