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

com.jtransc.game.util.Signal Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating Javascript and Haxe, with initial focus on Kotlin and games.

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy