chickensoft-games / AutoInject

Node-based dependency injection for C# Godot scripts at build-time, including utilities for automatic node-binding, additional lifecycle hooks, and .net-inspired notification callbacks.
https://www.nuget.org/packages/Chickensoft.AutoInject/
MIT License
97 stars 5 forks source link

feat: allow two-phase dependency resolution notifications #8

Closed jolexxa closed 1 year ago

jolexxa commented 1 year ago

this introduces a small change that allows for two callbacks to be invoked after dependencies are resolved. the new one, Setup, will be invoked before OnResolved if (and only if) the node's IsTesting flag (added to the node by this PowerUp) is set to false (which it is by default).

this makes it easier to unit test. often, you need to initialize values in production that you want to override in a test, but you need them in separate methods or you have no way to inject the fake stuff in.