com.jtransc.game.util.Signal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtransc-media-game Show documentation
Show all versions of jtransc-media-game Show documentation
JVM AOT compiler currently generating Javascript and Haxe, with initial focus on Kotlin and games.
package com.jtransc.game.util;
import java.util.ArrayList;
public class Signal {
public interface Handler {
void handle(T value);
}
ArrayList> handlers = null;
public void add(Handler value) {
if (handlers == null) {
handlers = new ArrayList>();
}
handlers.add(value);
}
public void remove(Handler value) {
if (handlers != null) {
handlers.remove(value);
}
}
public void dispatch(T value) {
if (handlers != null) {
for (Handler handler : handlers) {
handler.handle(value);
}
}
}
}