Appearance
ContextManager
Inherits: LibTSMModule
Functions
Create
lua
function BaseType.ContextManager.Create(enterFunc, exitFunc)
-> ContextManagerObjectCreates a context manager.
Parameters:
| Name | Type | Description |
|---|---|---|
enterFunc | fun(arg: A): E | The enter function which is called when the managed code block starts |
exitFunc | fun(arg: A, enterValue: E) | The exit function which is called when the managed code block completes |
Returns:
| Type | Description |
|---|---|
ContextManagerObject |
Methods
With
lua
function ContextManagerObject:With(arg, func, obj, key)
-> function, any, anyReturns an iterator which executes to completion with the context manager. NOTE: The iterator must not be interrupted (i.e. with a break or return).
Parameters:
| Name | Type | Description |
|---|---|---|
arg | any | A value to pass as the first argument to the enter and exit functions (must be non-nil) |
func | fun(obj: any, key?: any): ...any | The iterator function or nil to iterate exactly once |
obj | any | The object to pass to the iterator function |
key | any | The initial key to pass to the iterator function |
Returns:
| Type | Description |
|---|---|
function | |
any | |
any |