silphius/app/context/ecs.js

16 lines
330 B
JavaScript

import {createContext, useContext} from 'react';
import {usePacket} from './client.js';
const context = createContext();
export default context;
export function useEcs() {
return useContext(context);
}
export function useEcsTick(fn, dependencies) {
const ecs = useEcs();
usePacket(':Ecs', fn, [ecs, ...dependencies]);
}