Skip to content

Commit

Permalink
Update doc strings and give the action creator a more specific name.
Browse files Browse the repository at this point in the history
  • Loading branch information
huwshimi committed Apr 17, 2020
1 parent f3c98e8 commit 3d4d50c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ui/src/app/base/sagas/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
* @param {Array} machines - A list of machine ids.
* @returns {Array} The list of action creator functions.
*/
export const generateActionCreators = (machines) =>
export const generateMachinePoolActionCreators = (machines) =>
machines.map((machineID) => (result) =>
machineActions.setPool(machineID, result.id)
);
Expand All @@ -28,7 +28,7 @@ export function* createPoolWithMachines(
{ payload }
) {
const { machines, pool } = payload.params;
const actionCreators = yield call(generateActionCreators, machines);
const actionCreators = yield call(generateMachinePoolActionCreators, machines);
// Send the initial action via the websocket.
yield call(
sendMessage,
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/base/sagas/actions.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expectSaga } from "redux-saga-test-plan";
import * as matchers from "redux-saga-test-plan/matchers";

import { createPoolWithMachines, generateActionCreators } from "./actions";
import { createPoolWithMachines, generateMachinePoolActionCreators } from "./actions";

jest.mock("../../../websocket-client");

Expand All @@ -13,7 +13,7 @@ describe("websocket sagas", () => {
const pool = { name: "pool1", description: "a pool" };
const action = { payload: { params: { machines: ["machine1"], pool } } };
return expectSaga(createPoolWithMachines, socketClient, sendMessage, action)
.provide([[matchers.call.fn(generateActionCreators), actionCreators]])
.provide([[matchers.call.fn(generateMachinePoolActionCreators), actionCreators]])
.call(
sendMessage,
socketClient,
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/base/sagas/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ function* storeNextActions(nextActionCreators, requestIDs) {
*
* @param {Object} response - A websocket response.
*/
export function* handleNextActions({ request_id, result }) {
export function* handleNextActions(response) {
const { request_id, result } = response;
const actionCreators = yield call(getNextActions, request_id);
if (actionCreators && actionCreators.length) {
for (let actionCreator of actionCreators) {
Expand Down Expand Up @@ -339,6 +340,8 @@ export function* sendMessage(socketClient, action, nextActionCreators) {

/**
* Connect to the WebSocket and watch for message.
* @param {Array} messageHandlers - Sagas that should handle specific messages
* via the websocket channel.
*/
export function* setupWebSocket(messageHandlers = []) {
try {
Expand Down

0 comments on commit 3d4d50c

Please sign in to comment.