Module Dependency
Provides mechanisms to resolve dependencies and defer actions until specified dependencies are fulfilled.
Functions
Dependency.clear (dependency) | Marks the specified dependency as no longer fulfilled. |
Dependency.defer (onFill[, onClear], ...) | Postpones the execution of a function until all specified dependencies are fulfilled. |
Dependency.deferWidget (widget, ...) | Postpones the initialization and execution of a widget until all specified dependencies are fulfilled. |
Dependency.fill (dependency) | Marks the specified dependency as fulfilled. |
Tables
Dependency | Accessible fields. |
Functions
- Dependency.clear (dependency)
-
Marks the specified dependency as no longer fulfilled.
Any functions defered because of only this dependency that provided onClear function ends up being executed synchronously.
Parameters:
- dependency Dependency The dependency to mark as not fulfilled.
Usage:
Dependency.clear(Dependency.CustomName)
- Dependency.defer (onFill[, onClear], ...)
-
Postpones the execution of a function until all specified dependencies are fulfilled.
Remarks:
-
If all dependencies are fulfilled at the time of the call, the
onFill
function is executed synchronously. Otherwise, it is executed once the last dependency gets fulfilled. TheonClear
function is executed only if theonFill
function was already called, meaning it is not called if the dependencies are not fulfilled initially. Once at least one dependancy is cleared and filled again, theonFill
function may again be called once it is fulfilled again. If you want to disable this behaviour, you can do that be returningfalse
in theonClear
function.Parameters:
- onFill func Function, that should be executed once all dependencies are fulfilled.
- onClear
func
Optional parameter; function, that should be executed after
onFill
has been called and at least one dependency is cleared. (optional) - ... Dependency A list of dependencies that need to be fulfilled.
- Dependency.deferWidget (widget, ...)
-
Postpones the initialization and execution of a widget until all specified dependencies are fulfilled.
Also automatically removes the widget once the dependency is cleared.
This function has to be called only after all other widget setup code gets executed, which usually means the end of the script.
Remarks:
-
Only using Dependency.defer within the
Initialize
method of a widget is not enough, as the individual call-ins are still present and could be executed. And as they could end up being executed before the actualInitialize
code gets executed, it would produce errors. Hence always use Dependency.deferWidget if deferring the widget as a whole is required.Parameters:
- widget Widget Widget that is dependent to the dependencies.
- ... Dependency A list of dependencies that need to be fulfilled.
Usage:
Dependency.deferWidget(widget, Dependency.CustomName, Dependency.OtherName)
- Dependency.fill (dependency)
-
Marks the specified dependency as fulfilled.
Any functions defered because of only this dependency ends up being executed synchronously.
Parameters:
- dependency Dependency The dependency to mark as fulfilled.
Usage:
Dependency.fill(Dependency.CustomName)
Tables
- Dependency
-
Accessible fields.
Fields:
- A_Z__name__ Any slot with a capital first letter represents a Dependency that can be used to track what dependencies are fulfilled and allows the postponing of execution of functions and widgets.