Replies: 3 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
I am going to add some balance :) by saying that I AM a
|
Beta Was this translation helpful? Give feedback.
-
The biggest disconnect that I see is that then you'll be forced to use the I wish there was a way to make it optional. That way we could try it out. |
Beta Was this translation helpful? Give feedback.
-
I know everyone hates
this
in JavaScript, so I'm very much doubting whether this is a good idea. But I thought I'd point it out in a discussion, since IMO it does have some merit. The proposal is to change this:To this:
Before you say eugh, hear me out! Why might we want to do this?
Prior art
It is natural, in a way, because
click
is a method andthis
inside of a method refers to the object that the method operates on. This is natural, and familiar from all types of methods in JS land.Arity
Another argument for this is that it makes passing arguments to actions more natural:
From this:
To this:
Note that in the first example, the action definition takes two arguments, but when the action gets called it only takes one argument. This is weird. Who provides the other argument? In the second example, there is a natural link between the definition and the call site.
Filter delegation
Finally another argument is that we want to eventually allow some type of delegation for filters, this would require us to get a hold of some reference to the interactor. Since we pass the interactor as the first argument for actions, that's probably also what we'll want to do with filters. But most filters will not use that argument, so then we'll need to ignore this argument. Using
this
there is an easy, straightforward path to making filters and actions work the same way. There is no such option for any other API as far as I can see.Beta Was this translation helpful? Give feedback.
All reactions