1
0
Fork 0

add tests for runtime part adding

This commit is contained in:
Enoch Riese 2023-02-21 16:17:57 +02:00
parent 07a1a3c0f1
commit d4675d8648
2 changed files with 106 additions and 2 deletions

View file

@ -73,11 +73,14 @@ export function Pattern(designConfig) {
* @param {object} part - The part to add
* @return {object} this - The Pattern instance
*/
Pattern.prototype.addPart = function (part) {
Pattern.prototype.addPart = function (part, resolveImmediately = false) {
if (typeof part?.draft === 'function') {
if (part.name) {
this.designConfig.parts.push(part)
this.__initialized = false
if (resolveImmediately) {
this.store.log.debug(`Perfoming runtime resolution of new part ${part.name}`)
this.__resolvePart([part])
} else this.__initialized = false
} else this.store.log.error(`Part must have a name`)
} else this.store.log.error(`Part must have a draft() method`)