no.finn.unleash.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
package no.finn.unleash.event;
import no.finn.unleash.util.UnleashConfig;
import no.finn.unleash.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);
});
}
}