Open
Description
Add a [Tags]
symbol to support construction of instances with tags. Similar to [Children]
, except the elements are just strings:
-- Single tag construction.
New "Folder" {
[Tags] = "Foo",
}
-- Multiple tag construction.
New "Folder" {
[Tags] = {"Foo", "Bar"},
}
-- Nested tag construction.
New "Folder" {
[Tags] = {"Foo", "Bar", {"Baz"}},
}
Support for states?
local tag = State("Foo")
local folder = New "Folder" {
[Tags] = tag,
}
tag:set("Bar") -- Adds "Bar", removes "Foo".
local tagA = State("Foo")
local tagB = State("Foo")
local folder = New "Folder" {
[Tags] = {tagA, tagB},
}
tagA:set("Bar") -- Adds "Bar", "Foo" still retained by tagB.
tagB:set("Bar") -- Adds "Bar", removes "Foo".
local tags = State({"Foo", "Bar"})
local folder = New "Folder" {
[Tags] = tags,
}
tags:set({"Bar", "Baz"}) -- Removes "Foo", adds "Baz".
tags:set("Foo") -- Removes "Bar" and "Baz", adds "Foo".
This could make use of #10 under the hood if that is implemented. Alternatively, it could detect keys instead of values, but seems somewhat less convenient.
Another consideration is whether [Tags]
represents all tags on the instance, or only the tags known by bound states.
local tags = State({"Foo", "Bar"})
local folder = New "Folder" {
[Tags] = tags,
}
CollectionService:AddTag(folder, "Baz")
tags:set({"Bar"}) -- Removes "Foo", should this remove "Baz"?
[Children]
has a similar consideration, so [Tags]
should match whatever that does.
Metadata
Metadata
Assignees
Projects
Status
Todo