We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Observes
So there I am looking at the Jakarta CDI spec, and I find out about this useful technique available to them.
We could define an SPI for an event manager and an interface for sending events.
interface ObserverManager { <T> void registerEventListener(Consumer<T> observer, Type eventType); List<Consumer<T>> getObservers(Type eventType); } interface Event<T> { void fire(T); void fireAsync(T); } @interface EventType { }
Here's how I'm thinking a user would go about it.
Annotate an event class:
@EventType class MyEvent { //contents... }
And we'd generate the impl:
@Generated @Component class MyEventPublisher implements Event<MyEvent> { //inject the Observer Manager and implement publishing methods... }
The user can then inject this class and publish an event.
The user can add @Observes to a bean method to signify this should be registered in the manager.
@Singleton class MyObserver { //contents... void observeMyEvent(@Observes MyEvent) { //contents... } }
We'd then generate the DI class to also register this method to the ObserverManager.
ObserverManager
Thoughts?
The text was updated successfully, but these errors were encountered:
SentryMan
Successfully merging a pull request may close this issue.
So there I am looking at the Jakarta CDI spec, and I find out about this useful technique available to them.
We could define an SPI for an event manager and an interface for sending events.
Here's how I'm thinking a user would go about it.
Publishing
Annotate an event class:
And we'd generate the impl:
The user can then inject this class and publish an event.
Observing
The user can add
@Observes
to a bean method to signify this should be registered in the manager.We'd then generate the DI class to also register this method to the
ObserverManager
.Thoughts?
The text was updated successfully, but these errors were encountered: