BetterEventSystem 1.1.0
It has been moved to Addikted.BetterEventSystem
See the version list below for details.
dotnet add package BetterEventSystem --version 1.1.0
NuGet\Install-Package BetterEventSystem -Version 1.1.0
<PackageReference Include="BetterEventSystem" Version="1.1.0" />
<PackageVersion Include="BetterEventSystem" Version="1.1.0" />
<PackageReference Include="BetterEventSystem" />
paket add BetterEventSystem --version 1.1.0
#r "nuget: BetterEventSystem, 1.1.0"
#:package BetterEventSystem@1.1.0
#addin nuget:?package=BetterEventSystem&version=1.1.0
#tool nuget:?package=BetterEventSystem&version=1.1.0
BetterEventSystem
To create an event, simply create a new instance of the event class and pass it the name of the event.
new Event("my_event"). then, you can add listeners to the event by calling Event.AddEvent(listener) on the event instance.
note: listeners must take one argument, of the BetterEventSystem.EventArgs type
To get the event instance, simply call EventSystem.GetEvent("my_event"). this will also create the event if it doesnt exist (disable this by setting the safe paramater to true.
Finally, to broadcast / trigger the event, simply call Event.Broadcast().
If the event allows async (which it does by default), then the event will be broadcasted asynchronously.
You can call
Event.BroadcastSync() or Event.BroadcastAsync() to be explicit about the async nature of the broadcast.
You can pass any object to any of the broadcast methods, and it will be passed to all listeners in the EventArgs.data property.
Example:
using BetterEventSystem;
// create the event, and add a listener
new Event("my_event").AddListener((e) => {
Console.WriteLine("my_event was triggered");
});
// add another listener
EventSystem.GetEvent("my_event").AddListener((e) => {
Console.WriteLine("my_event was triggered, but I'm a different listener");
});
// this event doesnt exist, but it will be created with default values. you can edit the Event after creation if you want
EventSystem.GetEvent("my_other_event").AddListener((e) => {
Console.WriteLine("my_other_event was triggered");
});
Console.Write("Press any key to trigger events...");
Console.ReadKey(); // wait for user input
Console.Clear(); // clear the console
// trigger the event
EventSystem.GetEvent("my_other_event").Broadcast();
EventSystem.GetEvent("my_event").Broadcast();
Output:
my_other_event was triggered
my_event was triggered, but I'm a different listener
my_event was triggered
There are other things you can do with events, I will create more detailed docs on readthedocs soon. The code is pretty self explanatory, so check out the github!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.