You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was inspired by the Zustand API but it turns out actions are really useful for vanilla making me think it is better to flip this around and make it a core export that always takes a world to bind.
import{createActions}from'koota';constuseMyActions=createActions((world)=>({spawnShip: (position)=>world.spawn(Position(position),Velocity),destroyAllShips: (world)=>{world.query(Position,Velocity).forEach((entity)=>{entity.destroy();});},}));functionComponent(){constworld=useWorld()// Bind world manually. Can choose the world instead of getting it from context.const{ spawnShip, destroyAllShips }=useMyActions(world);}// This is the exact same API for vanilla.const{ spawnShip, destroyAllShips }=useMyActions(world);
The text was updated successfully, but these errors were encountered:
Right now
createActions
lives in the React package and gets used as a hook.And then can be used in vanilla with an additional API call that binds world to the actions manually.
This was inspired by the Zustand API but it turns out actions are really useful for vanilla making me think it is better to flip this around and make it a core export that always takes a world to bind.
The text was updated successfully, but these errors were encountered: