Skip to content

Instantly share code, notes, and snippets.

@ryan2clw
Last active August 23, 2019 18:15
Show Gist options
  • Save ryan2clw/d56d24eafe9cfcc833a92ed47ca48adf to your computer and use it in GitHub Desktop.
Save ryan2clw/d56d24eafe9cfcc833a92ed47ca48adf to your computer and use it in GitHub Desktop.
Action types for python bingo
import { action as act } from 'typesafe-actions'
import actionTypes from './actionTypes';
import { Reducer } from 'redux'
/* Message Actions */
export const success = (message: string) => act(actionTypes.ALERT_SUCCESS, message);
export const danger = (message: string) => act(actionTypes.ALERT_DANGER, message)
export const clear = () => act(actionTypes.ALERT_CLEAR);
export interface IMessageState {
readonly type: string,
readonly message: string
}
const initialState = {
message: "",
type: "alert-clear",
}
/* Message Reducer */
const messageReducer: Reducer<IMessageState> = (state = initialState, action) => {
switch (action.type) {
case actionTypes.ALERT_SUCCESS:
return {
message: action.payload,
type: 'alert-success',
};
case actionTypes.ALERT_DANGER:
return {
message: action.payload,
type: 'alert-danger',
};
case actionTypes.ALERT_CLEAR:
return {
message: action.payload,
type: 'alert-clear',
};
default:
return state
}
}
export { messageReducer }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment