Skip to content

jordanstudioroot/RootEvents-UnityCSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RootEvents

A lightweight publisher-subscriber framework used by Studio Root Games. Can be copied directly into a project, turned into a Unity Package Manager package, or added to a project initialized as an npm package using npm install jordanstudioroot/RootEvents-UnityCSharp.

Requirements

Usage

  1. Declare an event by instantiating a new RootEvent: RootEvent<Argument, Response> foo = new RootEvent<Argument, Response>();
  2. Subscribe a function of the corresponding signature to the event by passing it as an argument to the event: foo.Subscribe(HandlerFunction);
  3. Fire the event as needed, passing the object publishing the event and any required arguments to the event: foo.Publish(this, argument);
  4. When the event is no longer relevant to a particular object, or in general, call foo.Unsubscribe(HandlerFunction); or foo.UnsubscribeAll();

Recommendations

Declare the events in a central event aggregator if you have numerous events and numerous subscribers.

TODO

  • Tests
  • Example event aggregator class.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published