io.getunleash.event.EventDispatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unleash-client-java Show documentation
Show all versions of unleash-client-java Show documentation
A client library for Unleash
The newest version!
package io.getunleash.event;
import io.getunleash.util.UnleashConfig;
import io.getunleash.util.UnleashScheduledExecutor;
public class EventDispatcher {
private final UnleashSubscriber unleashSubscriber;
private final UnleashScheduledExecutor unleashScheduledExecutor;
public EventDispatcher(UnleashConfig unleashConfig) {
this.unleashSubscriber = unleashConfig.getSubscriber();
this.unleashScheduledExecutor = unleashConfig.getScheduledExecutor();
}
public void dispatch(UnleashEvent unleashEvent) {
unleashScheduledExecutor.scheduleOnce(
() -> {
unleashSubscriber.on(unleashEvent);
unleashEvent.publishTo(unleashSubscriber);
});
}
}