package framework.subject;

import android.view.InputEvent;

import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import framework.listener.MyListener;

public abstract class MySubject {
    protected Set<MyListener> listenerSet = new CopyOnWriteArraySet<MyListener>();

    public void addListener(MyListener listener) {
        listenerSet.add(listener);
    }

    protected void notifyListeners(InputEvent event) {
        for (MyListener listener : listenerSet) {
            listener.onEvent(event);
        }
    }
}
