All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.finn.unleash.event.EventDispatcher Maven / Gradle / Ivy

There is a newer version: 4.4.1
Show newest version
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);
        });
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy