-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Method Chaining #928
Comments
I think functions should have meaningful results that are relevant and predictable to what the function does. I think this principle should go before counting characters when designing an API. I think almost all of these functions can return a result that can be useful in some scenario. Fluent APIs are probably one of the most abused API design patterns. |
According to a previous implementation, #212, we simply need to see a good level of people requesting the functionality. For now it is possible to implement it in a wrapper system, so we'd rather not have it in core unless there is a strong need for it. |
Well, I don't disagree with @Janpot. Everyone has their own perspective, that's why there are debates over Atom/Sublime, Mocha/Jest, Single Quote/Double Quote, Vue/React, Same line Braces/ Different line Braces. From my perspective, I have a really huge file with lots of lines you know, and if I repeat the await page.doThis()
await page.doThat()
await page.doSomething() etc. multiple times, that Let's see if someone else want's this too. :) Should I close this issue and wait for someone else to create a similar issue? |
Ah, ok, if it's as a secondary API like in #212 I have no problem with it. But then it'd probably make more sense as a wrapper package? Like |
Honestly, my recommendation here is someone build a wrapper to provide a chainable API. That can then be used and tested live in its own space and once any issues are hammered out it could be brought up for discussion to be included in core. That keeps the core focus here on the primary API until launch. While allowing people to have a chain option to spot issues and work out kinks in case it decides to be brought into core. And if it still doesn't make it into core, you just have a solid wrapper package for developers to use who want that style. |
yep, makes more sense as a "userland" package |
I like the If someone comes up with one, we'd be happy to refer to it from our docs. |
Did anyone happen to make this? https://npmjs.com/package/node-horseman did it really fkn beautifully |
You can chain the commands on other Nightmare, Chromeless etc. You can provide selector along with type(). Like the following. A total of 188 characters. The chain methods are still doable with the seperate awaits.
for the same thing we have to write the await multiple times. A total of 244 characters.
What should be done to achieve the chain methods for clean coding and innerpeace?
The text was updated successfully, but these errors were encountered: