context
Constructors: context.new
Types
Context type
luau
type Context<T> = setmetatable<{
default: T,
provided: { [types.Scope]: T },
provided_frame: { [types.Scope]: number },
}, typeof(context)>Contexts can provide a value to a scope, including scopes keyed inside it.
Functions
new
luau
context.new<T>(default: T): Context<T>Returns a new context with the default value.
Methods
provide
luau
context:provide<T>(scope: types.Scope, value: T): TProvides a value to a scope, including scopes keyed inside it.
clear
luau
context:clear<T>(scope: types.Scope)Clears the value provided to a scope, but does not touch scopes keyed inside it.
get
luau
context:get<T>(scope: types.Scope): TReturns the provided value from the closest scope, or the default value where none are provided.
destroy
luau
context:destroy<T>()Destroys the context, clearing it's provided scopes.
