Skip to content

innerScope -> Scope<T>

function Fusion.innerScope<Existing, AddMethods...>(
    existing: Scope<Existing>,
    ...: (AddMethods & {})...
): Scope<merge(Existing, AddMethods...)>

Returns a blank scope with the same methods as an existing scope, plus some optional additional methods which are merged in to only the new scope.

Unlike deriveScope, the returned scope is an inner scope of the original scope. It exists until either the user calls doCleanup on it, or the original scope is cleaned up.

Pseudo type

Luau doesn't have adequate syntax to represent this function.

Scopes are not unique

Fusion can recycle old unused scopes. This helps make scopes more lightweight, but it also means they don't uniquely belong to any part of your program.

As a result, you shouldn't hold on to scopes after they've been cleaned up, and you shouldn't use them as unique identifiers anywhere.


Parameters

existing : Scope<T>

An existing scope, whose methods should be re-used for the new scope.

... : AddMethods...

A series of tables, ideally including functions which take a scope as their first parameter. Those functions will turn into methods on the scope.


Returns -> Scope<T>

A blank inner scope with the same methods as the existing scope, plus the extra methods provided.


Learn More

Back to top