-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
From @Ctrlmonster:
Any chance we could pass our own type into createActions (with the default just being world), similar to how directed lets you define what goes into the system args?
Example: I'd like to define action stores for levels and it'd be nice to be able to control the signature for calling the store. Right now it can only be world, which feels unnecessary restrictive given that I'm defining the function and am responsible for providing the args
// define a store that takes in world and extra args (in this case a level entity) const LevelActions = createActions((world: World, level: Entity) => ({ spawn() { const entity = world.spawn(); entity.add(PartOfLevel(level)); return entity; }, destroy() { world.query(PartOfLevel(level)).forEach(e => e.destroy()); } })); // --- // somewhere else when using the store const {spawn, destroy} = LevelActions(world, someLevelEntity); ...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels