-
Notifications
You must be signed in to change notification settings - Fork 29
[discussion] maybe change the name of the context parameter from 'hook' to 'context' or use 'this' in the future? #159
Comments
People seem to just not like using I've also run into (transpiling?) issues passing params with Your comments about 'rationalizing' naming have always been spot on. However it may be wiser to not use |
hmmm, I have never used hooks with babel... I agree |
I like the separation of hook = function. |
|
I have been considering
|
I do like |
FWIW I 100% agree with @daffl's comment. I'd like to see |
I'm thinking about non-English speakers. Would `state` be easier to
understand?
…On Wed, May 10, 2017 at 12:39 PM, Eric Kryski ***@***.***> wrote:
FWIW I 100% agree with @daffl <https://github.com/daffl>'s comment. I'd
like to see context. Also, related feathersjs/feathers#562
<feathersjs/feathers#562>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#159 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABeznxs8oW7G6gJfce3jlvOtYnQ8IM7vks5r4ehZgaJpZM4NRpRI>
.
|
As a non English speaker I think state might be more ambiguous than context. Context has one and only one specific meaning which is easier to understand. |
The renaming has started with feathersjs-ecosystem/feathers-hooks-common#200 . An issue has been created for the rest feathersjs-ecosystem/feathers-hooks-common#201 . |
Currently the hook function written as
(hook) => {...; return hook; }
is somehow confusing for many new users. The termhook
has two meanings here: the function itself is called a hook or a hook function, but the context parameter passed into the hook function is also calledhook
.In fact the parameter naming is arbitrary, and calling it
hook
is just a convention or a tradition of feathers which is initiated in the official docs. So I propose to (in the future) change the docs and rename it to something more clear, likecontext
or so. So people usecontext.app
,context.path
etc. instead ofhook.app
,hook.path
.Another possible options is to use
this
instead of a parameter to pass the context object into the hook function. So people just usethis.app
orthis.path
... I knowthis
in hook function used to point to the current service object, so this might have some backward compatibility issues. But on the other hand, today we have the new syntax of arrow functions=>
which keepsthis
and we don't need to manually bindthis
again and again, which makes the use ofthis
in such situation quite concise and elegant and appealing.The text was updated successfully, but these errors were encountered: