bevyengine / bevyengine/bevy

Fallible component lifecycle hooks

Open
#24,314 0 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Feature S-Ready-For-Implementation X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Currently, a [component lifecycle hook](https://docs.rs/bevy/latest/bevy/ecs/lifecycle/type.ComponentHook.html) only accepts a `fn(DeferredWorld<'_>, HookContext)`.

This means that you cannot propagate errors from inside a lifecyle hook.

## What solution would you like?

Make it so that lifecycle hooks can accept a `fn(DeferredWorld<'_>, HookContext) -> Result`, just like systems and observers.

This way a user can use `?` from inside lifecycle hooks too.

## What alternative(s) have you considered?

Litter your code with `.unwrap()` or `.expect(...)`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.