From 496f36385590bb3ad8649ffe65071284b112e9d0 Mon Sep 17 00:00:00 2001 From: Porfirio Date: Tue, 27 Jun 2017 12:50:15 +0100 Subject: [PATCH 1/2] Add options to meta --- src/gen/js/genReduxActions.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gen/js/genReduxActions.ts b/src/gen/js/genReduxActions.ts index 803cb6a..f0341d6 100644 --- a/src/gen/js/genReduxActions.ts +++ b/src/gen/js/genReduxActions.ts @@ -58,7 +58,7 @@ ${isTs ? `export type ${actionComplete} = ${returnType}${ST}`: ''} export function ${op.id}(${paramSignature})${isTs? ': any' : ''} { return dispatch => { - dispatch({ type: ${actionStart}, meta: { info } })${ST} + dispatch({ type: ${actionStart}, meta: { info, options } })${ST} return ${op.group}.${op.id}(${params}) .then(response => dispatch({ type: ${actionComplete}, @@ -66,7 +66,8 @@ export function ${op.id}(${paramSignature})${isTs? ': any' : ''} { error: response.error, meta: { res: response.raw, - info + info, + options } }))${ST} }${ST} From 6ce142d8ce8a1770d2440c5b4ab40816f9a35e00 Mon Sep 17 00:00:00 2001 From: Porfirio Date: Mon, 17 Jul 2017 09:07:50 +0100 Subject: [PATCH 2/2] Only add options if it has any --- src/gen/js/genReduxActions.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gen/js/genReduxActions.ts b/src/gen/js/genReduxActions.ts index f0341d6..71c4299 100644 --- a/src/gen/js/genReduxActions.ts +++ b/src/gen/js/genReduxActions.ts @@ -37,6 +37,7 @@ import * as ${name} from '../${name}'${ST} function renderReduxActionBlock(spec: ApiSpec, op: ApiOperation, options: ClientOptions): string { const lines = [] const isTs = options.language === 'ts' + let hasOptions='' const actionStart = camelToUppercase(op.id) + '_START' const actionComplete = camelToUppercase(op.id) const infoParam = isTs ? 'info?: any' : 'info' @@ -45,6 +46,7 @@ function renderReduxActionBlock(spec: ApiSpec, op: ApiOperation, options: Client const required = op.parameters.filter(param => param.required) let params = required.map(param => param.name).join(', ') if (required.length < op.parameters.length) { + hasOptions=', options' if (required.length) params += ', options' else params = 'options' } @@ -58,7 +60,7 @@ ${isTs ? `export type ${actionComplete} = ${returnType}${ST}`: ''} export function ${op.id}(${paramSignature})${isTs? ': any' : ''} { return dispatch => { - dispatch({ type: ${actionStart}, meta: { info, options } })${ST} + dispatch({ type: ${actionStart}, meta: { info${hasOptions} } })${ST} return ${op.group}.${op.id}(${params}) .then(response => dispatch({ type: ${actionComplete}, @@ -66,8 +68,7 @@ export function ${op.id}(${paramSignature})${isTs? ': any' : ''} { error: response.error, meta: { res: response.raw, - info, - options + info${hasOptions} } }))${ST} }${ST}