import { ajax } from 'rxjs/ajax';
import { map } from 'rxjs/operators';
import { actionCreator } from '../rx-redux';
export const baseActions = {
    loadConfig: actionCreator((payload) => {
        if (typeof payload === 'string') {
            return {
                type: 'CONFIG_LOADING',
                payload: ajax(payload).pipe(map((xhr) => {
                    return {
                        type: 'CONFIG_LOADED',
                        payload: xhr.response
                    };
                }))
            };
        }
        else {
            return {
                type: 'CONFIG_LOADED',
                payload: payload
            };
        }
    }),
    addConfig: actionCreator((payload) => {
        return {
            type: 'ADD_CONFIG',
            payload: payload
        };
    }),
    setConfig: actionCreator((key, value) => {
        let payload = {};
        payload[key] = value;
        return {
            type: 'ADD_CONFIG',
            payload: payload
        };
    }),
};
//# sourceMappingURL=base-actions.js.map