markdalgleish / redial

Universal data fetching and route lifecycle management for React etc.
1.1k stars 42 forks source link

catch unwanted removal of returning a dispatch #52

Open briziel opened 6 years ago

briziel commented 6 years ago

Hi,

Thank you for your awesome work. I want to propose this PR, because me and some folks of my team are running into an issue which is hard to identify and VERY time consuming.

const redial = { fetch: ({ dispatch, httpClient, props }) => dispatch(loadThings(httpClient, props.things)) };

When you have a redial object like this, you have no hint that it is necessary for fetch to return a promise. This is going to be a problem when you start debugging and put curly braces around the body of arrow function.

const redial = { fetch: ({ dispatch, httpClient, props }) => { console.log("props", props); dispatch(loadThings(httpClient, props.things)); } };

I couldn't think of any usecase where you don't want to return a promise to resolve after async operation. Maybe i'am wrong. What do you think?

greetings Fabricius

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-2.4%) to 97.561% when pulling 9e3ef4cb6f88459d136af687963352feaabdc920 on briziel:master into 3ef620b7cedb0a48f18629f3dd5302998ee38de0 on markdalgleish:master.