Accept `opts.func` for Plugin API
See original GitHub issueCurrent: plugin(name, opts, func)
The func
parameter should be read as the fallback.
func = opts.func || func
This allows for cleaner plugin (inline & external) definitions; especially if relying on the default every
and files
settings.
// external
this.plugin('myName', {
files: true,
every: false,
*func(arr) {
// `arr` is all files
}
})
// external w/defaults
this.plugin('myName', {
*func(file) {
// loop each `file` object
}
})
// inline w/defaults
exports.fooTask = function * (fly) {
yield fly.source('foo/*').run({
*func(file) {
// loop each `file` object
}
}).target('bar')
}
Reference: https://github.com/flyjs/fly/issues/233#issuecomment-274749015
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Options API | Plugin Developer Handbook
The Options API, added in WordPress 1.0, allows creating, reading, updating and deleting of WordPress options. In combination with the…
Read more >Creating Apollo Server plugins - Apollo GraphQL Docs
To create a plugin that accepts options, create a function that accepts an options object and returns a properly structured plugin object, like...
Read more >Plugins - Fastify
Creating a plugin is very easy, you just need to create a function that takes three parameters, the fastify instance, an options object,...
Read more >Falco Plugins Go SDK Walkthrough
The SDK provides options for configuring and overriding all the default values: // sdk/plugins/source func WithInstanceContext(ctx context.
Read more >terraform-plugin-sdk/serve.go at main - GitHub
Terraform Plugin SDK enables building plugins (providers) to manage any service providers or custom in-house solutions - terraform-plugin-sdk/serve.go at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jbucaran No problem. So what do you think on the newer suggestion?
It also could mean for simpler external plugins (aka, installed via NPM):
cc: @devmondo @hzlmn @watilde