package common;

import java.util.HashSet;
import java.util.Set;

public class Signal {

	private final Set<Runnable> listeners;

	public Signal() {
		this.listeners = new HashSet<>();
	}

	public void connect(Runnable listener) {
		this.listeners.add(listener);
	}

	public void clear() {
		this.listeners.clear();
	}

	public void emit() {
		for (Runnable listener : this.listeners) {
			listener.run();
		}
	}
	
	// public void disconnect(Runnable listener) {
	// 	this.listeners.remove(listener);
	// }
}
