Farmbot-Web-App/frontend/connectivity/actions.ts

18 lines
482 B
TypeScript
Raw Normal View History

2017-09-28 12:07:34 -06:00
import { Actions } from "../constants";
2017-09-29 13:46:08 -06:00
import { Edge, EdgeStatus } from "./interfaces";
import { ReduxAction } from "../redux/interfaces";
2017-09-28 12:07:34 -06:00
2017-09-29 13:46:08 -06:00
type NetChange = ReduxAction<EdgeStatus>;
2017-12-29 09:47:54 -07:00
const change = (state: "up" | "down") =>
2019-09-11 15:58:53 -06:00
(name: Edge, at = (new Date()).getTime()): NetChange => {
2017-12-29 09:47:54 -07:00
return {
type: Actions.NETWORK_EDGE_CHANGE,
2019-09-11 15:58:53 -06:00
payload: { name, status: { state, at } }
2017-09-29 13:46:08 -06:00
};
2017-12-29 09:47:54 -07:00
};
2017-09-29 13:46:08 -06:00
export const networkUp = change("up");
export const networkDown = change("down");