WebComponen decorator uses middleware system to handle options.
Example of such middleware is a function setting template of custom element.
template
setTemplate.js
export default target => options => { const template = createTemplate(options.template); if (template) { target.appendChild(template); } return options }
And here is how middleware is applied to custom elements
createTarget.js
import applyMiddleware from './applyMiddleware' import setTemplate from './middleware/setTemplate' export default original => options => { return function (...args) { let constructor = original.apply(this, args); let target = constructor; applyMiddleware(setTemplate)(target)(options) return constructor; } }
applyMiddleware method accepts middleware functions.
applyMiddleware
applyMiddleware(mid1, mid2, mid3)
If web-component library is missing something ? Or you want to add some features, simply fork this repository, add middleware and create pull request.
There was an error while loading. Please reload this page.