-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: add support for lazily replacing variables #1388
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,20 @@ _.assign(Variable.prototype, /** @lends Variable.prototype */ { | |
return (!_.isNil(value) && _.isFunction(value.toString)) ? value.toString() : E; | ||
}, | ||
|
||
/** | ||
* Runs the value function and updates the variable to store | ||
* the return value of the function | ||
* | ||
* @returns {String} | ||
*/ | ||
async populate () { | ||
const value = await this.valueOf(); | ||
|
||
this.valueOf(value); | ||
this.valueType(typeof value); | ||
this.lazy = false; | ||
}, | ||
|
||
/** | ||
* Typecasts a value to the {@link Variable.types} of this {@link Variable}. Returns the value of the variable | ||
* converted to the type specified in {@link Variable#type}. | ||
|
@@ -208,6 +222,7 @@ _.assign(Variable.prototype, /** @lends Variable.prototype */ { | |
_.has(options, 'system') && (this.system = options.system); | ||
_.has(options, 'disabled') && (this.disabled = options.disabled); | ||
_.has(options, 'description') && (this.describe(options.description)); | ||
_.has(options, 'lazy') && (this.lazy = options.lazy); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @appurva21 Thoughts on this approach? Some other approaches I thought about
|
||
} | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appurva21 Thoughts on supporting async updates this way? This feels weird but I didn't want to touch the
_.mergeWith
andcustomizer
fns. Or do you think it's okay if we write a custom implementation formergeWith
which supports async replaces ?