Rename onState -> onStateChange
timwis opened this issue · comments
For what it's worth: Prior to yesterday, I had only lightly glanced through the barracks docs, and was confused by what onState
meant -- I assumed it was a callback for when .state()
was run (to get the current state) or something. Obviously a more thorough read of the docs would have made it clearer, but I figured this might make a good readability suggestion - a method name like onStateChange
or onStateUpdate
etc. would have been instantly clear. Just wanted to get the suggestion in soon because it would be part of choo's API too.
/cc @anandthakker (we were chatting about it yesterday), @dereklieu
Yeah, think .onStateChange()
is reasonable enough - bit lengthier but sure, if you think it's confusing then there's no harm in updating it. Should probably update the rest of the hook methods too so they stay consistent.
Would be a breaking change for barracks tho - I guess hurray for semver haha ✨
.onChange()
would work too, though it may be worth getting other folks' feedback on whether this adds value before implementing it. Could be just me!
Hmm, not sure I'd go with .onChange()
as it isn't clear what has changed - The state? The view?