Support tags
Anaminus opened this issue · 0 comments
Anaminus commented
Support tags
Tags should be supported somehow.
Considerations:
- We can have multiple DataModels.
- We want to scope by DataModel, or globally.
- Use descriptor extensions (#65) to configure the serialized property for tags?
- The property used for tags can be changed on the fly. How would this interact with the tag database?
- Treat configuration differently; to get tag support, config must be applied globally to all instances, and cannot be refined per instance.
- Implement by only considering config of rbxmk.globalDesc?
- The property used for tags can be changed on the fly. How would this interact with the tag database?
- Instead, skip descriptor extensions. Use distinct API instead.
- For global database, use
rbxmk.tags
.- Value is a type that matches the CollectionService API without actually being an instance.
- Can configure tag property (default "Tags").
- Changing this does a complete database reevaluation.
- Can configure class used for database scoped to DataModel (default "CollectionService").
- What happens to existing instances of previous class? The additional behavior just drops. Would have to be implemented as a condition.
- Can produce variation that scopes each method to a particular instance. This considers only the instance and its descendants.
- For DataModel-scoped database, match CollectionService API?
- Would be union of Instance and above
tags
type. - Would be accessed via CollectionService instance under game. Class can be configured.
- To support on the fly configuration of the class, this is implemented as a condition, similar to how GetService works for DataModel.
- Selects scope by getting parent DataModel.
- Would be union of Instance and above
Tags API
- Type name?
Tags
TagCollection
TagDatabase
Tags:WithScope(scope: Instance?): Tags
- Return Tags that limits database to tree of scope.
- Can scope out as well as in.
- If scope is nil, scope is global.
- Support multiple scopes? result is a union of each scope.
- Ideally does not require any setup. Should be cheap to run.
Tags:GetTagProperty(): string
- Gets the name of the property used to serialize tags.
Tags:SetTagProperty(name: string, transferMethod: Enum.TagTransferMethod = Move)
- Sets the name of the property used to serialize tags.
- transferMethod determines what to do with existing tag properties.
Tags.ScopingClass: string?
- Gets or sets the name of the class treated as CollectionService.
- Can be set to nil to disable.
- Initially set to "CollectionService".
- Reflected APIs:
Tags:AddTag(instance: Instance, tag: string)
- Add tag to instance.
Tags:GetAllTags(): {string}
- Get list of all tags.
Tags:GetTagged(tag: string): Objects
- Get list of instances tagged with tag.
Tags:GetTags(instance: Instance): {string}
- Get list of tags for instance.
Tags:HasTag(instance: Instance, tag: string): boolean
- Return whether instance has tag.
Tags:RemoveTag(instance: Instance, tag: string)
- Remove tag from instance.
Adds rbxmk.Enum.TagTransferMethod
, which determines how SetTagProperty handles properties of the previous and next names:
Item | Value | Previous property | Next property |
---|---|---|---|
None | 0 | Untouched | Untouched |
Copy | 1 | Untouched | Set from previous |
Move | 2 | Removed | Set from previous |