24 lines
399 B
JavaScript
24 lines
399 B
JavaScript
/* @flow */
|
|
|
|
import { SUCCESS, ERROR } from './constants'
|
|
|
|
type Success = {
|
|
type: typeof SUCCESS,
|
|
message: string
|
|
}
|
|
|
|
type Error = {
|
|
type: typeof ERROR,
|
|
error: string
|
|
}
|
|
|
|
function handleStatus(status: Success | Error) {
|
|
switch(status.type) {
|
|
case SUCCESS:
|
|
console.log(`Successful: ${status.message}`);
|
|
break;
|
|
default:
|
|
console.log(`Errored: ${status.error}`);
|
|
}
|
|
}
|