-
Notifications
You must be signed in to change notification settings - Fork 353
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 hooks section #1090
Add hooks section #1090
Conversation
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.
Looking good @andrew-fleming. Left a suggestion to simplify the code. Not sure if we should update the Medium post accordingly.
} | ||
|
||
// Occurs after token transfers | ||
fn after_update( |
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.
We now can have default function implementations in traits, so we can simplify this pattern by setting default empty functions in the Hooks trait, removing the need for an empty function in the custom impl. I think we can use this PR for that as well.
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.
Note that the default empty impl is still helpful, but it should be refactored to an empty (without functions) impl definition, since the empty functions should come from the Hook trait definition itself.
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.
I think this example shouldn't include the empty function, but maybe a note stating that the default for the other hook functions is an empty implementation.
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
@ericnordelo It's probably enough to just include a note in the post ("As of v0.15.1..."). The default fns doesn't break the old flow. I'll wait until near the next release though |
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.
LGTM!
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.
Looks good!
Fixes #979.
PR Checklist