Allow the CollectionService to manage any type of class

The CollectionService is something that I’d really like to make use of.
Unfortunately at the moment, it only tracks the following classes:

  • Configuration
  • CustomEvent
  • CustomEventReceiver
  • Dialog
  • VehicleSeat

I’d like to propose the following changes:

  1. All classes should be tracked by the CollectionService
  2. GetCollection should not return RobloxLocked instances if called from a Script/LocalScript
  3. ItemAdded/ItemRemoved should have a 2nd parameter called isRobloxLocked, so we can check if we have permission to modify the object (or better yet, make it so the event doesn’t fire from Scripts/LocalScripts if the object is RobloxLocked)

New API:

CollectionService:BindToCollectionWatch(string listenerName, string className, function (Instance item, bool isAdded) onItemChanged)

Adds a listener function that is only invoked when a specific instance type is added or removed.
This would be useful in the case that you only want to listen to one class, and you don’t want this specific function being invoked for all classes being added because you’d have to do an IsA check on each.

CollectionService:UnbindFromCollectionWatch(string listenerName)

Unbinds a listener with the specified listenerName

Why this would be useful:

Sometimes developers (myself included) want to make specific changes to all instances in the game of a specific type. Depending on the situation, this may require us to do a lot of recursion, and if we want to continue tracking these objects, we have to setup a DescendantAdded listener, which can get a bit expensive when there are a lot of Instances being moved around (especially in the Workspace). Having a direct access port to specific instance types would make these kinds of things much easier to do, and less expensive.