Skip to content

Instantly share code, notes, and snippets.

@lucas-jones
Created January 26, 2020 12:17
Show Gist options
  • Save lucas-jones/88e8f02a87a3871f92f5d86b6d2c5001 to your computer and use it in GitHub Desktop.
Save lucas-jones/88e8f02a87a3871f92f5d86b6d2c5001 to your computer and use it in GitHub Desktop.
abstract class System<T extends { [index:string]:Component[] }> {
query: { [P in keyof T]?: QueryCollection<T[P][]> }
}
class QueryCollection<T> {
components:T;
listen?: {
added?: (value:T) => void;
removed?: (value:T) => void;
}
}
type RenderSystemQuery = {
"sprites": [ Sprite, Transform ]
}
class RenderSystem extends System<RenderSystemQuery> {
constructor() {
super()
this.query.sprites.components.forEach(([sprite, tranform]) => {
});
this.query.sprites.listen.added = ([Sprite, Transform]) => {
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment