-
Notifications
You must be signed in to change notification settings - Fork 57
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
Consider renaming init_resource
to then_init_resource
#244
Comments
I would like to find a name that does not depend on the call position. You can configure different parts of a loading state in multiple places, so the methods should read well everywhere. But I agree that it would be good to rename the method to distinguish it from Bevy's What do you think about |
Yeah I like that better than what we have today because it makes it really clear the "init_resource" is something that happens afterwards, not at the time you call the function in the builder. app.add_loading_state(
LoadingState::new(MyState::Preloading)
.continue_to_state(MyState::Preloaded)
.load_collection::<MyAssetCollection>()
.load_collection::<MyAssetCollection2>()
.finally_init_resource::<MyResource>(),
); I'd still say to keep an eye out for any design that emerges wrt some |
init_resource
because it's the same name as Bevy'sapp.init_resource
, but it's slightly different.then_
prefix flowing a bit better when reading a loading state.Before:
After:
To me this reads clearer in that the resource is going to be initialised once all asset collections are loaded.
It could be even better if it was a bug to use a
then_init_resource
in the wrong position of the builder. For example, this wouldn't compile:Not sure what builder term you'd need to throw in there, maybe something like
collect
(shrug, don't love the term):You might have some better ideas for a more fluent API here. E.g. maybe the argument to
add_loading_state
could remain as it is, but you can callapp.add_loading_state().when_ready_init_resource::<MyResource>()
instead.P.S. Not sure if
then_init_resource
orand_then_init_resource
would be better / more idiomatic.If you prefer not to have a change like, feel free to close the issue, it's just some feedback from using the API here and it feeling a bit "messy", if I can say that.
The text was updated successfully, but these errors were encountered: