I'm playing around with Ramda and FP with an react-project. I want to learn a bit more to write clean code with FP, and so I overthink every line if there exists a bether or cleaner way. Now I'm here with this problem and I cannot find a solution which makes me happy:
const mapErrorToErrorNode = (onUnknownError, transformUnknownError, getKnownError) => R.pipe(
R.prop('error'),
handleErrorIfExists(onUnknownError, transformUnknownError, getKnownError),
R.assoc('errorNode', R.__, {}),
);
I have to pass all parameters to the inner function as arguments. Of course, this works but its just not really nice. If I'm changing the signature of the inner function I also have to change it in this function-call. One solution would also be:
const mapErrorToErrorNode = (...args) => R.pipe(
R.prop('error'),
R.apply(handleErrorIfExists, args),
R.assoc('errorNode', R.__, {}),
);
Am I missing something or is this the best approach?
(for more context what I'm trying to do, you can look at this Ramda REPL.)
(and I already looked at How do I pass in multiple parameters into a Ramda compose chain?, but I do not think that this applies for my question or maybe I just don't get it)