-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add store.use() method #58
Conversation
Oh, to clarify: no breaking changes. Minor version |
// push an object of hooks onto an array | ||
// obj -> null | ||
function useHooks (hooks) { | ||
assert.equal(typeof hooks, 'object', 'barracks.use: hooks should be an object') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typeof [] === 'object'
If we're looking for an object literal the only way to be positive it's that is to do the unwieldy:
Object.prototype.toString.call(hooks) === '[object Object]'
Hurry for a prototypical inheritance system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, you're obv right... Except that it's valid to append properties onto an array and so it would parse as expected 😂. Not that we should encourage that but, JS is def a weird language. #keepjavascriptweird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a fun language!
This is cool with me if we don't mind the arrays part? (We could always |
@toddself yeah, I'm not too fussed about it - feel like the |
Welp, think this is good to merge then ✨ |
released as |
Allows declaring multiple hooks through
store.use(hooks)
. All hooks will now be executed on every call. Useful to register multiple handlers and stuff ✌️