vigetlabs / microcosm

Flux with actions at center stage. Write optimistic updates, cancel requests, and track changes with ease.
http://code.viget.com/microcosm/
MIT License
487 stars 29 forks source link

Pass form as second argument to action callbacks #431

Closed nhunzaker closed 6 years ago

nhunzaker commented 6 years ago

Right now it's hard to reset a form when an action completes. This commit adds the form as the second argument of these callbacks, making this easier:

class MyForm extends React.Component {
  onDone(_payload, form) { 
    form.reset()
  }

  render() {
    return (
      <ActionForm action="doSomething" onDone={this.onDone}>
        ...
      </ActionForm>
    )
  }
}

Fixes: https://github.com/vigetlabs/microcosm/issues/424

codecov-io commented 6 years ago

Codecov Report

Merging #431 into master will increase coverage by 3.9%. The diff coverage is 97.29%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #431     +/-   ##
=========================================
+ Coverage   84.19%   88.09%   +3.9%     
=========================================
  Files          44       44             
  Lines        1303     1310      +7     
  Branches      241      239      -2     
=========================================
+ Hits         1097     1154     +57     
+ Misses        173      131     -42     
+ Partials       33       25      -8
Impacted Files Coverage Δ
packages/microcosm/src/microcosm.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/coroutine.js 100% <100%> (ø) :arrow_up:
packages/microcosm-preact/src/action-form.js 100% <100%> (ø) :arrow_up:
packages/microcosm-preact/src/action-button.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/addons/action-form.js 97.5% <93.33%> (+97.5%) :arrow_up:
packages/microcosm/src/action.js 100% <0%> (+9.09%) :arrow_up:

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 c6f8895...4d1fb2d. Read the comment docs.

efatsi commented 6 years ago

👍