Skip to content

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

Description

@hmans

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} />
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions