Skip to content

Conversation

@evansiroky
Copy link
Contributor

  • allow debouncing of trip plan requests
  • add option to not auto-plan trips

* allow debouncing of trip plan requests
* add option to not auto-plan trips
}
}

let debouncedPlanTrip // store as global, so it can be reused. Maybe there's a better way?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevorgerhardt let me now if there is a better way to do this. Since a new function is returned on each formChanged event I put the debouncedPlanTrip variable in this scope so it would be available in subsequent calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If debouncePlanTimeMs can change then you would need to recreate the debounced function when it does. If it can't change then it's application configuration and shouldn't be retrieved within the function and can be created once with dispatch passed in as a parameter:

const debouncedPlanTrip = debounce(({dispatch}) => dispatch(planTrip()), DEBOUNCE_PLAN_TIME_MS)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the debounce time is a variable that comes from the store, so it could change. I updated my code so that it'll update the debounce function if that happens.

@codecov-io
Copy link

codecov-io commented Apr 5, 2017

Codecov Report

Merging #24 into dev will increase coverage by 2.35%.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##             dev     #24      +/-   ##
========================================
+ Coverage   7.43%   9.79%   +2.35%     
========================================
  Files         36      36              
  Lines        619     623       +4     
========================================
+ Hits          46      61      +15     
+ Misses       573     562      -11
Impacted Files Coverage Δ
lib/reducers/create-otp-reducer.js 0% <ø> (ø) ⬆️
lib/actions/form.js 100% <100%> (+100%) ⬆️
lib/actions/api.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5fbfce...fef275f. Read the comment docs.

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's just me, but I think the debounce logic is a little hard to follow. I'd like to see some comments in actions/form.js that describe what's going on a little more clearly.

@evansiroky
Copy link
Contributor Author

I added some comments for you, @landonreed. lmk if it makes sense.

@evansiroky evansiroky merged commit 7049707 into dev Apr 5, 2017
@evansiroky evansiroky deleted the form-control branch April 5, 2017 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants