Hey folks, I cleaned up an open source plugin I made that I wanted to share:
https://github.com/strayTrain/SimpleEventSubsystemPlugin/
You can use it to send and receive events from (almost) anywhere.
A cool feature is the ability to add a payload to these events and that payload can be any arbitrary struct.
Use case example
Problem:
- You have a Main Menu widget that has a nested Options Menu widget.
- The Options Menu widget has a "Save Settings" button.
- Your Options Menu widget requires a hard reference to the root Main Menu widget in order to call an event dispatcher that triggers a SaveSettings function somewhere.
- This scenario happens in many other places and gets messy over time, making you sad.
Solution:
- Using the subsystem, on the parent widget you listen for an event e.g. "Events.ButtonClicked" and a domain "EventDomains.OptionsMenu"
- In the child widget you send the event.
- You remember that you can attach arbitrary structs with events so you add the current values in the settings menu as a payload to the event.
- No more custom event dispatchers, no more tangled UI. Feels are good.