-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
res.format(): call default using obj
as the context
#3587
Conversation
And a question: is there a reason |
This is very interesting, thank you! The As for the PR, most users are using the |
You're correct, but the object method syntax (used in the OP) is also quite convenient here (and is even shorter by one character).
Since the non-default handlers are already receiving 3 arguments, this would have to be the 4th, right? How about we
With this PR, the default and non-default handlers are both called with the |
3c0f668
to
cb85e62
Compare
I know this is old and was forgotten about, but still seems relevant. I updated your PR to add a test case. I think the point about |
cb85e62
to
18241eb
Compare
18241eb
to
9482b82
Compare
... so that it may refer to the other handlers via
this
. This is useful for cases where you want to delegate thedefault
behavior to one of the other registered handlers, e.g.:Without this, I have to pre-declare the default
json
handler separately, making it inconsistent with how the non-default handlers are declared and making the overall code more complex:The regular (non-
default
) handlers are already called with theobj
as their context, so this would match their behavior too.