add tests for runtime part adding
This commit is contained in:
parent
07a1a3c0f1
commit
d4675d8648
2 changed files with 106 additions and 2 deletions
|
@ -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`)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue