src/main/java/org/openjfx/core/Channel.java
@Override
    public Unsub onMessage(MessageObject.SubjectEnum subjectEnum, Consumer callback, boolean isDiscardHistoryMessage) {
        if (callback == null) {
            return null;
        }
        if (!isDiscardHistoryMessage) {
            Object lastMessageData = this.lastMessage.get(subjectEnum);
            if (lastMessageData != null) {
                try {
                    callback.accept(lastMessageData);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        ArrayList<Consumer> listenersForTheSubject = this.listeners.get(subjectEnum);
        if (listenersForTheSubject == null) {
            listenersForTheSubject = new ArrayList<>();
        }
        listenersForTheSubject.remove(callback);
        listenersForTheSubject.add(callback);
        this.listeners.put(subjectEnum, listenersForTheSubject);

        return (Unsub) () -> this.listeners.remove(subjectEnum, callback);

    }
/**
     * Message listeners
     *
     * @param subjectEnum
     * @param callback
     * @param isDiscardHistoryMessage - if set to true, only new message would be fired to the listener
     * @return
     */
Message listeners
@param subjectEnum
@param callback
@param isDiscardHistoryMessage - if set to true, only new message would be fired to the listener
@return
Message listeners @param subjectEnum @param callback @param isDiscardHistoryMessage - if set to true only new message would be fired to the listener @return
@Override
    public Unsub onMessage(MessageObject.SubjectEnum subjectEnum, Consumer callback, boolean isDiscardHistoryMessage) {
        if (callback == null) {
            return null;
        }
        if (!isDiscardHistoryMessage) {
            Object lastMessageData = this.lastMessage.get(subjectEnum);
            if (lastMessageData != null) {
                try {
                    callback.accept(lastMessageData);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        ArrayList<Consumer> listenersForTheSubject = this.listeners.get(subjectEnum);
        if (listenersForTheSubject == null) {
            listenersForTheSubject = new ArrayList<>();
        }
        listenersForTheSubject.remove(callback);
        listenersForTheSubject.add(callback);
        this.listeners.put(subjectEnum, listenersForTheSubject);
        return (Unsub) () -> this.listeners.remove(subjectEnum, callback);
    }
@ Override public Unsub onMessage ( MessageObject . SubjectEnum subjectEnum , Consumer callback , boolean isDiscardHistoryMessage ) { if ( callback == null ) { return null ; } if ( ! isDiscardHistoryMessage ) { Object lastMessageData = this . lastMessage . get ( subjectEnum ) ; if ( lastMessageData != null ) { try { callback . accept ( lastMessageData ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } ArrayList < Consumer > listenersForTheSubject = this . listeners . get ( subjectEnum ) ; if ( listenersForTheSubject == null ) { listenersForTheSubject = new ArrayList < > ( ) ; } listenersForTheSubject . remove ( callback ) ; listenersForTheSubject . add ( callback ) ; this . listeners . put ( subjectEnum , listenersForTheSubject ) ; return ( Unsub ) ( ) -> this . listeners . remove ( subjectEnum , callback ) ; }
Message listeners
 @param subjectEnum
 @param callback
 @param isDiscardHistoryMessage - if set to true, only new message would be fired to the listener
 @return
Message listeners @param subjectEnum @param callback @param isDiscardHistoryMessage - if set to true only new message would be fired to the listener @return