The For Objects
Import Weave.ForPairs, Weave.ForKeys, or Weave.ForValues from the Weave module.
1 2 3 4 | |
Weave has functions for turning Weave Value or Computed into an Instance
local playerNames = Value.new({ "Kreekcraft", "Sleitnick" })
ForValues(playerNames, function(name)
return Attach(TextLabel:Clone()) {
Text = name,
Parent = screenGui
}
end)
✨ For function update state automatically ✨
playerNames.set({ "Sleitnick" }) -- "Kreekcraft" TextLabel is Destroyed
For functions turn Weave state into UI.
ForPairs turns state into UI.Usage¶
For functions take
-
A Weave
ComputedorValuetable. -
A function that returns an
Instance
local playerNames = Value.new({"Elttob", "boatbomber", "thisfall", "AxisAngles"})
ForValues(playerNames, someFunction)
Where someFunction
-
Receives a value from the table
-
Returns an
Instance
ForValues(playerNames, function(name)
local textLabel = TextLabel:Clone()
return Attach(textLabel) {
Text = playerName,
Parent = ScreenGui
}
end)
Over the next few pages, we'll take a look at three state objects:
ForValues: values in a table.ForKeys: keys in a table.ForPairs: keys and values in a table.