react-resource-router icon indicating copy to clipboard operation
react-resource-router copied to clipboard

update function should accept just new data

Open ayhanyunt12 opened this issue 3 years ago • 1 comments

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)

ayhanyunt12 avatar Sep 30 '22 06:09 ayhanyunt12

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.

anacierdem avatar Sep 30 '22 07:09 anacierdem