-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tag] for CollectionService tags #36
Comments
Since tags are unordered like properties, a possible alternative API: New "Folder" {
[Tag "Foo"] = true,
[Tag "Bar"] = true,
} Though this eliminates the possibility of binding a set of tags. On the other hand, this would be a good solution if binding sets of tags were expressly unwanted. |
This is an interesting idea! I'm assuming this is talking about CollectionService tags? |
I would go for the first option, having a tags symbol like children. On a similar note, this should probably be added for attributes too? |
Tracking that here: #1 |
The design of this API will probably be guided by #1 |
Tags shouldn't be designed like Attributes. How would it even work in actual code? All keys need a value, so do we just have to set it to true in all cases because yes? Do we make the value a boolean which controls if it has that tag or not? It also looks a lot harder to guess what the value that we set it to means. New "Frame" {
[Tag "MyTag"] = true
} This looks incredibly awkward to read imo. In comparison to the original proposal, New "Frame" {
[Tags] = {"MyTag"}
} This looks way better in my eyes as we aren't pretending to store some magical value. |
I think we'll go for |
Will any excess tags be removed automatically? Eg if |
Regarding extraneous tags, Fusion would have to deliberately go out of its way to remove them, and that would be an unnecessary step from Fusion's PoV. To implement tag states, Fusion would just be making calls to AddTag and RemoveTag as needed to reconcile state changes. As long as a tag isn't involved in this state, then it would remain untouched. Regarding the syntax, my original use-case only used tags as constants, so I don't really have a stake in either. But I can try to imagine scenarios that involve state objects. The local itemRelatedTags = Value({}::{string})
local weaponRelatedTags = Value({}::{string})
local sword = Sword {
[Tags] = {
itemRelatedTags,
weaponRelatedTags,
},
}
itemRelatedTags:set({"Durability", "Countable"}) -- sword gains Durability and Countable.
weaponRelatedTags:set({"Durability", "Damaging"}) -- sword gains Damaging.
itemRelatedTags:set({}) -- sword loses Countable.
weaponRelatedTags:set({}) -- sword loses Damaging. Meanwhile, the same behavior with the local itemRelatedTags = Value({}::{[string]:true})
local weaponRelatedTags = Value({}::{[string]:true})
local sword = Sword {
[Tag "Durability"] = Computed(function(use)
return use(itemRelatedTags.Durability) or use(weaponRelatedTags.Durability)
end),
[Tag "Countable"] = Computed(function(use)
return use(itemRelatedTags.Countable)
end),
[Tag "Damaging"] = Computed(function(use)
return use(weaponRelatedTags.Damaging)
end),
}
itemRelatedTags:set({Durability=true, Countable=true})
weaponRelatedTags:set({Durability=true, Damaging=true})
itemRelatedTags:set({})
weaponRelatedTags:set({}) While awkward for this particular scenario, we're being much more deliberate about what tags are defined on the instance, which might be seen as a benefit in some situations. I think it depends on the situation, and I'd wager that both syntaxes have their ideal use-cases. If I really had to pick a side, I'd be on team por-que-no-los-dos. |
Yeah this is the sort of thing I'm thinking about. We could do both perhaps, no reason not to. This perhaps could inform the reactive tag APIs in #206 |
Both? Both. Both. Both is good. But we'll divvy it up a bit; if we're adding So what I'll do is I'll limit the scope of this particular change to |
Add a
[Tags]
symbol to support construction of instances with tags. Similar to[Children]
, except the elements are just strings:Support for states?
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.[Children]
has a similar consideration, so[Tags]
should match whatever that does.The text was updated successfully, but these errors were encountered: