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

io.getunleash.event.EventDispatcher Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy