v0.6.4 - Agora
This is another maintenance release fixing a bunch of bugs reported thanks to @dylanhu7, mostly related to ordered relations and patterns around accessing and traversing graphs.
In addition, I took the opportunity to rename autoRemoveTarget to autoDestroy and expand its abilities. autoRemoveTarget was a misnomer as it was actually the source entity that was automatically removed, but even if this was renamed it would still not be exactly clear. I settled on autoDestroy with the options 'orphan' | 'source' | 'target', where 'orphan' and 'source' are aliases for each other. This is much more clear as the usual way we want to use this is to deal with orphans created in a graph by destroying a parent entity.
const ChildOf = relation({ autoDestroy: 'orphan' }) // Or 'source'
const parent = world.spawn()
const child = world.spawn(ChildOf(parent))
const grandchild = world.spawn(ChildOf(child))
parent.destroy()
world.has(child) // False, the child and grandchild are destroyed tooBut you can now flip the relation if the relation is meant to be used in the other direction, like a Contains that points to an item where you want to destroy the target item if the entity that contains it is also destroyed.
const Contains = relation({ autoDestroy: 'target' })
const container = world.spawn()
const itemA = world.spawn()
const itemB = world.spawn()
container.add(Contains(itemA), Contains(itemB))
container.destroy()
world.has(itemA) // False, items are destroyed with containerWhat's Changed
Feat
Fixed
- core: Ensure entity cleanup with ordered relations and
autoDestroyby @krispya in #217 - core: Structural changes to ordered relations flag changes by @krispya in #219
- react:
useQuerycould error when a relation target changes by @krispya in #220
Chore
Full Changelog: v0.6.3...v0.6.4