Skip to content

Releases: falkreon/TinyEvents

2.0.0

02 Mar 17:57
fb7be3c
Compare
Choose a tag to compare

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.

1.0

30 Mar 13:03
51346dd
Compare
Choose a tag to compare
1.0

Amazingly, TinyEvents had never been released. Now it has.

  • RunnableEvent just fires callbacks, like a delegate method with an empty signature
  • ConsumerEvent gives event listeners one piece of data
  • BiConsumerEvent gives event listeners two pieces of data, although it's usually better to use a record type with Consumers

Thread safety is still in progress; events can be fired and registered only on the thread that created them, but listeners can specify executors for their own execution.