hookstate
hookstate copied to clipboard
Add set() and revert() to Initial plugin
Implements #208
This allows you to reset what "initial" is for things like editing forms when you save the form but might want to "edit" and "cancel" after saving.
Since set(s)
takes a state value you can use it to set it to any arbitrary state.
The revert()
method sets the current state to whatever initial was. This could technically be accomplished with Initial(state).set(Initial(state).get())
, but would be a handy shortcut.
Codecov Report
Merging #209 (7807a16) into master (2ff4d5f) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #209 +/- ##
=======================================
Coverage 88.88% 88.88%
=======================================
Files 1 1
Lines 603 603
Branches 170 170
=======================================
Hits 536 536
Misses 67 67
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 2ff4d5f...7807a16. Read the comment docs.
@avkonst made some updates. I found some other issues with the set and revert functions and those are also now fixed.
Unfortunately I'm not sure I have time right at the moment to really test the nested state stuff. It is working for flat state at the moment.
I can probably get around to properly testing it in a few days or so if you want me to make sure that's working before merging it.