<commit_before>// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

export function requestData(type) {
    return {
        type
    };
}

export function requestSuccess(type, data) {
    return {
        type,
        data
    };
}

export function requestFailure(type, error) {
    return {
        type,
        error
    };
}

export function emptyError() {
    return {
        id: '',
        message: '',
        detailed_error: '',
        status_code: ''
    };
}

export function bindClientFunc(clientFunc, request, success, failure, ...args) {
    return (dispatch, getState) => {
        function onRequest() {
            dispatch(() => requestData(request), getState);
        }

        function onSuccess(data) {
            dispatch(() => requestSuccess(success, data), getState);
        }

        function onFailure(err) {
            dispatch(() => requestFailure(failure, err), getState);
        }

        return dispatch(() => clientFunc(onRequest, onSuccess, onFailure, ...args), getState);
    };
}<commit_msg>Made client callbacks return the results of their dispatch calls<commit_after>// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

export function requestData(type) {
    return {
        type
    };
}

export function requestSuccess(type, data) {
    return {
        type,
        data
    };
}

export function requestFailure(type, error) {
    return {
        type,
        error
    };
}

export function emptyError() {
    return {
        id: '',
        message: '',
        detailed_error: '',
        status_code: ''
    };
}

export function bindClientFunc(clientFunc, request, success, failure, ...args) {
    return (dispatch, getState) => {
        function onRequest() {
            return dispatch(() => requestData(request), getState);
        }

        function onSuccess(data) {
            return dispatch(() => requestSuccess(success, data), getState);
        }

        function onFailure(err) {
            return dispatch(() => requestFailure(failure, err), getState);
        }

        return dispatch(() => clientFunc(onRequest, onSuccess, onFailure, ...args), getState);
    };
}
{'fraction_non_alphanumeric': 0.12433392539964476, 'fraction_numerical': 0.003552397868561279, 'mean_word_length': 2.2890510948905107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7520851', 'n_tokens_mistral': 611, 'n_tokens_neox': 594, 'n_words': 162}