ForPairs -> For<KO, VO> ¶
function Fusion.ForPairs<KI, KO, VI, VO, S>(
scope: Scope<S>,
inputTable: UsedAs<{[KI]: VI}>,
processor: (Use, Scope<S>, key: KI, value: VI) -> (KO, VO)
) -> For<KO, VO>
Constructs and returns a new For state object which processes keys and values in pairs.
Use scoped() method syntax
This function is intended to be accessed as a method on a scope:
local forObj = scope:ForPairs(inputTable, processor)
Parameters¶
scope : Scope<S> ¶
The scope which should be used to store destruction tasks for this object.
inputTable : UsedAs<{[KI]: VI}> ¶
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, value: VI) -> (KO, VO) ¶
Accepts a KI
key and VI
value pair from the input table, and returns the
KO
key and VO
value pair 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, VO> ¶
A freshly constructed For state object.