package com.twu.biblioteca.ui.auth;

import com.twu.biblioteca.auth.AuthenticationListener;
import com.twu.biblioteca.ui.MenuItemListener;
import com.twu.biblioteca.util.Broadcaster;

public class LogoutController implements MenuItemListener {
    private final Broadcaster<AuthenticationListener> listeners = new Broadcaster<>(AuthenticationListener.class);
    private final LogoutView view;

    public LogoutController(LogoutView view) {
        this.view = view;
    }

    public void addListener(AuthenticationListener listener) {
        listeners.addObserver(listener);
    }

    @Override
    public void itemSelected() {
        listeners.broadcast().loggedOut();
        view.showLogoutSucceeded();
    }
}
