Skip to content

ForKeys -> For<KO, V>

function Fusion.ForKeys<KI, KO, V, S>(
    scope: Scope<S>,
    inputTable: UsedAs<{[KI]: V}>,
    processor: (Use, Scope<S>, key: KI) -> KO
) -> For<KO, V>

Constructs and returns a new For state object which processes keys and preserves values.

Use scoped() method syntax

This function is intended to be accessed as a method on a scope:

local forObj = scope:ForKeys(inputTable, processor)


Parameters

scope : Scope<S>

The scope which should be used to store destruction tasks for this object.

inputTable : UsedAs<{[KI]: V}>

The table which will provide the input keys and input values for this object.

If it is a state object, this object will respond to changes in that state.

processor : (Use, Scope<S>, key: KI) -> KO

Accepts a KI key from the input table, and returns the KO key that should appear in the output table.

The processor is given a use function for including other objects in the computation, and a scope for queueing destruction tasks to run on re-computation. The given scope has the same methods as the scope used to create the whole object.


Returns -> For<KO, V>

A freshly constructed For state object.


Learn More

Back to top