Skip to content

2.0.0

Latest
Compare
Choose a tag to compare
@falkreon falkreon released this 02 Mar 17:57
· 1 commit to main since this release
fb7be3c

This is a near-complete rework of the event system, keeping its original goals but rethinking the implementation.

  • Events are now generic, so ConsumerEvent becomes Event<Consumer>, and RunnableEvent becomes Event<Runnable>.

  • This allows a great proliferation of event types using just the Event class and various functional interfaces. Factory methods for many of these possibilities are now available in EventFactories and ChainEventFactories

  • EventFactory<T> objects can make instances of Event<T>. Many instances of these are also provided.

If you're familiar with Fabric events, the new system should feel very familiar.

Each Event has an invoker object with the same type as event-handlers. This invoker can be used to fire events and collect the event's result. Regular events use reducer functions to turn the set of event responses into a single result that the invoker returns. Chain events hand the result of each handler to the next handler, so the invoker's return value is the output of the last handler.