react-resource-router
react-resource-router copied to clipboard
update function should accept just new data
As per the documentation current update method accepts a callback function, we have some cases where we get the latest version of data entirely from the backend and we write logics like
promise(body).then(res => update(() => res))
Maybe changing update method can accept both of them?
update(currentData => ({ ...currentData, username: newUsername, })
update(latestData)
And usage would be more flexible.
promise(body).then(update)
It is possible to make it point-free by a few ramda helpers;
.then(converge(update, [always(res)])) // or
.then(chain(update, always(res)))
Not ideal, and I agree, accepting the final data from the original update API is a reasonable request.