Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer bound ECS.useEntities(world => bucket) API #267

Open
hmans opened this issue Nov 30, 2022 · 0 comments
Open

Offer bound ECS.useEntities(world => bucket) API #267

hmans opened this issue Nov 30, 2022 · 0 comments
Assignees

Comments

@hmans
Copy link
Owner

hmans commented Nov 30, 2022

Have createReactAPI return a bound version of useEntities whose single argument is either a bucket, or a function returning a bucket. When the function form is used, a reference to the world the hook is bound to is passed into that function's first argument.

So instead of this:

import { ECS } from "./state"

const Asteroids = () => {
  const asteroids = useEntities(ECS.world.with("asteroid"))
  return <ECS.Entities in={asteroids} />
}

you'd now do this:

import { ECS } from "./state"

const Asteroids = () => {
  const asteroids = ECS.useEntities((world) => world.with("asteroid"))
  return <ECS.Entities in={asteroids} />
}
@hmans hmans added this to the Miniplex 2.0.0 milestone Nov 30, 2022
@hmans hmans self-assigned this Nov 30, 2022
@hmans hmans changed the title Offer alternative useEntities(function: () => Bucket, deps: any[]) interface Offer bound ECS.useEntities(world => bucket) API Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant