I have 2 functions that I will add in a lodash flow:
function normalizedFormFields(fields) { // needs only 1 argument
return _.mapValues( fields, function( value ) {
return { 'content': value };
} );
}
function mergedModelAndFormFieldss(model, normalizedFormFields) {
return _.merge( {}, model, normalizedFormFields )
}
const execution = _.flow( normalizedFormFields, mergedModelAndFormFieldss )
const errorMessageBag = function( fields, model ) {
return execution( fields, model ) // initiate flow with 2 arguments
}
As you can see the first function normalizedFormFields takes one argument. The second one needs 2: the value returned from the previous function (which is the normal behavior of flow), and another one: model.
But in the errorMessageBag invocation, I launch the flow process with 2 arguments. How to have the second argument, available to the second function in addition to the returned product of first function ? As you see the problem is that the first function in the flow takes and need only one argument. Is this a kind of situation where "curry" should come into play ? Please illustrate.