Function chorus.lazy

async chorus.lazy(delayed: (string | fun(): (table | function))): any
async chorus.lazy()

Lazily import module or evaluate function

If no argument is provided, the current configuration source is suspended. This allows delineating a portion of the configuration source that should be run only lazily.

If an argument is provided, returns a proxy object. When this object is indexed or called:

  • The configuration source is resumed and run to completion if needed

  • The argument is run (if a function) or required (if a string) and the result cached, if not already

  • The index or call operation is performed and returned

Modules or functions that return an object other than a table or function are not supported.

Parameters:

delayed ((string | fun(): (table | function))) – Module name or function