‹— back

subscribing to tears

Trying to figure out a way to have quick, entirely type safe and low overhead event subscriptions. This solution has 100% type safe private data passed per event type, and seems totally fine for now with no intense client-side setup.

First, declare event types.

Just below that, map private data types to events - a Player__Cried notification should always take a Player pointer.

When the player cries they can send that event out to the world.

And that notification will be received by anything that subscribed to that event, with hard-typed private data passed.

No templating means if the type declaration and the expectations of the observer don't match, there are two simple lines of error message.

Definitely needs battle testing but it looks totally reasonable so far, I feel kinda smart??? It's not the prettiest use of macros but it works and every way I've tried to break it has been stable so far.