Closed soccermax closed 5 months ago
Why using now activate?
do be in sync with the feature-toggles. Returning the activate function is the latest and greatest for plugins to execute the activate coding only for active plugins
Why using now activate?
do be in sync with the feature-toggles. Returning the activate function is the latest and greatest for plugins to execute the activate coding only for active plugins
How can plugins be deactivated?
Why using now activate?
do be in sync with the feature-toggles. Returning the activate function is the latest and greatest for plugins to execute the activate coding only for active plugins
How can plugins be deactivated?
Why using now activate?
do be in sync with the feature-toggles. Returning the activate function is the latest and greatest for plugins to execute the activate coding only for active plugins
How can plugins be deactivated?
I couldn't find that part anymore. I'll check tmr. But returning an promise is the desired way described by CAP:
/**
* Load and activate cds-plugins from project's package dependencies.
* Used in and made available through cds.plugins.
*/
exports.activate = async function () {
const DEBUG = cds.debug ('plugins', {label:'cds'})
DEBUG && console.time ('[cds] - loaded plugins in')
const { plugins } = cds.env, { local } = cds.utils
await Promise.all (Object.entries(plugins) .map (async ([ plugin, conf ]) => {
DEBUG?.(`loading plugin ${plugin}:`, { impl: local(conf.impl) })
// TODO: support ESM plugins. But see cap/cds/pull/1838#issuecomment-1177200 !
const p = require (conf.impl)
if(p.activate) {
cds.log('plugins').warn(`WARNING: \n
Returning an 'activate' function is deprecated and won't be
supported in future releases. → Please return a Promise with 'module.exports' instead.
`)
await p.activate(conf)
}
return p
}))
DEBUG && console.timeEnd ('[cds] - loaded plugins in')
return plugins
}
But returning an promise is the desired way described by CAP:
Exactly, I guess activate function is legacy, and only a promise shall be returned or nothing if not necessary to have something async...
fix https://github.com/cap-js-community/event-queue/issues/106