Coroutine icon indicating copy to clipboard operation
Coroutine copied to clipboard

How exactly do your events work?

Open Shadowblitz16 opened this issue 2 years ago • 3 comments

How exactly do your events work? They don't seem to take in EventArgs and they don't seem to support multiple subscribers.

Shadowblitz16 avatar Jun 01 '23 17:06 Shadowblitz16

Hi! Coroutine events aren't traditional C# events, they're just called the same.

You can find info about how to raise and wait for coroutine events in the README, but essentially, all that coroutine events are is a cue for a coroutine to wait for, rather than waiting for time to pass.

Possible use cases for this are waiting until an object has been updated in a game, or waiting until a loading screen has passed.

Please let me know if you have any specific questions!

Ellpeck avatar Jun 01 '23 17:06 Ellpeck

Shouldn't they at least be a delegate? I don't see why a class is used

Shadowblitz16 avatar Jun 01 '23 18:06 Shadowblitz16

Waiting for events doesn't involve delegates.

Events are single-instance (or you can extend Event and override Equals if you need to), and waiting for an event just waits for the next time that the event is raised. There is no additional data being passed, and there are no traditional event subscriptions involved.

Ellpeck avatar Jun 01 '23 18:06 Ellpeck