-
-
Notifications
You must be signed in to change notification settings - Fork 956
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
Simpler instance creation #707
Simpler instance creation #707
Conversation
This comment has been minimized.
This comment has been minimized.
Can you show how this will make it easier to create reusable plugins for Got? |
d0fb8c7
to
830c821
Compare
I like the direction of this. I was sceptical at first with overloading |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I still like to see #707 (comment). |
It is:
I will try to think of something. |
https://github.com/szmarczak/got/blob/simpler-instances/documentation/lets-make-a-plugin.md In this case I'll mention about mixing it with |
31e190f
to
30cea78
Compare
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>
05a4176
to
f9e7b2a
Compare
Looks great! 🙌 |
The same instances, but their creation is much simpler.
Now:
instanceA.extend(instanceB, instanceC, ...)
Before:
got.mergeInstances(instanceA, instanceB, instanceC, ...)
Now:
instanceA.extend(optionsB, optionsC, ...)
Before:
instanceA.extend(optionsB).extend(optionsC).extend(...)
Now:
instanceA.extend(optionsB, instanceC, ...)
Before:
got.mergeInstances(instanceA.extend(optionsB), instanceC)
Now:
instanceA.extend({handlers: [handlerB]})
Before:
got.mergeInstances(instanceA, got.create({handler: handlerB}))
Now:
instanceA.extend({mutableDefaults: true})
(not changed)Before:
instanceA.extend({mutableDefaults: true})
Are there any breaking changes?
got.create({handler: ...})
is pluralized and accepts an array.defaults.handler
was a function containing private array of handlers.defaults.handlers
is a public array of handlers.This allows us to inherit properties from the original Promise.
Yup, it's safe to use async handlers now. All the properties (
.cancel()
etc.) will be proxied.got.mergeInstances(...instances)
is deprecated. UseinstanceA.extend(instanceB)
instead.Checklist
handler
method ingot.create()
should be able to be an async function #701IssueHunt Summary
Referenced issues
This pull request has been submitted to:
handler
method ingot.create()
should be able to be an async functionIssueHunt has been backed by the following sponsors. Become a sponsor