I'm using Zenject, but this can apply to other frameworks as well. I'm not thrilled with boiler-plate code that i have to copy/paste all over. In this case, OnEnable should subscribe to a signal, OnDisable should unsubscribe. Can an attribute be written to make this a bit tighter?
ex:
private void Construct(SignalBus signalBus) { _signalBus = signalBus; }
private void OnEnable() { _signalBus.Subscribe<MyCustomPropertiesChangedSignal>(HandleMyCustomPropertiesChanged); }
private void OnDisable() { _signalBus.TryUnsubscribe<MyCustomPropertiesChangedSignal>(HandleMyCustomPropertiesChanged); }
I'd like to be able to simplify this perhaps more like this:
[SubscribeEnable (MyCustomPropertiesChangedSignal)]
void HandleMyCustomPropertiesChanged (MyCustomPropertiesChangedSignal signal)
{
....
}
Is that even possible?