From f2556c6a82f527b50e448913f4cf29ed5bc2972e Mon Sep 17 00:00:00 2001 From: Philipp Heuer Date: Fri, 4 Feb 2022 19:43:14 +0100 Subject: [PATCH] chore: update readme / bump to 0.10.0 --- README.md | 74 +++++++++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index d5d9400..8939e0a 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,34 @@ # *Events4J* -# Description +[![Latest](https://img.shields.io/github/release/PhilippHeuer/events4j/all.svg?style=flate&label=latest)](https://search.maven.org/search?q=com.github.philippheuer.events4j) -A simple wrapper to dispatch/consume events. +Click the module name in the table below for specific import instructions. (gradle, maven, ...) -# Import +| Module | Description | Coordinates | +|:-----------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------|------------------------------------------------------------------| +| [events4j-api](https://search.maven.org/artifact/com.github.philippheuer.events4j/events4j-api/0.10.0/jar) | contains all interfaces | com.github.philippheuer.events4j:events4j-api:0.10.0 | +| [events4j-core](https://search.maven.org/artifact/com.github.philippheuer.events4j/events4j-core/0.10.0/jar) | contains the EventManager implementation | com.github.philippheuer.events4j:events4j-core:0.10.0 | +| [events4j-kotlin](https://search.maven.org/artifact/com.github.philippheuer.events4j/events4j-kotlin/0.10.0/jar) | improvements for usage in kotlin projects | com.github.philippheuer.events4j:events4j-kotlin:0.10.0 | +| [events4j-handler-simple](https://search.maven.org/artifact/com.github.philippheuer.events4j/events4j-handler-simple/0.10.0/jar) | a simple synchronous event handler | com.github.philippheuer.events4j:events4j-handler-simple:0.10.0 | +| [events4j-handler-reactor](https://search.maven.org/artifact/com.github.philippheuer.events4j/events4j-handler-reactor/0.10.0/jar) | a event handler using project reactor | com.github.philippheuer.events4j:events4j-handler-reactor:0.10.0 | +| [events4j-handler-spring](https://search.maven.org/artifact/com.github.philippheuer.events4j/events4j-handler-spring/0.10.0/jar) | forward events to spring ApplicationEventPublisher | com.github.philippheuer.events4j:events4j-handler-spring:0.10.0 | -Maven: +# Description -Add the repository to your pom.xml with: -```xml - - - central - https://repo1.maven.org/maven2/ - - -``` -and the dependency: (latest, you should use the actual version here) - -```xml - - com.github.philippheuer.events4j - events4j - 0.9.8 - pom - -``` +**Events4J** provides the following features: -Gradle: - -Add the repository to your build.gradle with: -```groovy -repositories { - mavenCentral() -} -``` - -and the dependency: -```groovy -compile 'com.github.philippheuer.events4j:events4j:0.9.8' -``` +- publish events +- register consumers / listeners for events +- comes with a few prebuilt handlers that you can use out of the box +- provide your custom implementation to process events however you want # Usage ## Initialization ```java -// new instance -EventManager eventManager = new EventManager(); - -// register modules automatically -eventManager.autoDiscovery(); +EventManager eventManager = new EventManager(); // new instance +eventManager.autoDiscovery(); // register modules automatically ``` ## Event Producer @@ -74,9 +51,7 @@ eventManager.registerEventHandler(reactorEventHandler); The Consumer ```java reactorEventHandler.onEvent(TestEvent.class).subscribe(event -> { - log.info("Received event [{}] that was fired at {}.", - event.getEventId(), - event.getFiredAt().toInstant().toString()); + log.info("TestEvent received"); }); ``` @@ -96,7 +71,7 @@ public class TestEventListener { @EventSubscriber public void onTestEvent(TestEvent testEvent) { - System.out.println("TestEvent Listener Executed."); + System.out.println("TestEvent received"); } } @@ -109,7 +84,7 @@ eventManager.registerListener(new TestEventListener()); #### Spring Events -Include the Events4J-Spring Dependency and use spring properties to configure the handler: +Configure the following in your `application.properties` to enable spring application events: ```yaml events4j.handler.spring.enabled: true @@ -120,13 +95,14 @@ events4j.handler.spring.enabled: true ```java @EventListener public void handleContextStart(TestEvent testEvent) { - System.out.println("Spring Event received."); + System.out.println("TestEvent received"); } ``` -### Kotlin extension functions +## Kotlin + +The kotlin module allows the usage of [flows](https://kotlinlang.org/docs/flow.html) to consume events. -Set up Kotlin in your project and include the Events4J-Kotlin dependency. ```kotlin eventManager.flowOn() .collect { testEvent ->