I don’t know where I found it or what my sudden urge to learn about it is, but here I am.
There seems to be a Roblox-specific pseudo-object that developers are creating called Maid (in RoStrap, it’s Janitor). I think I may have gained a general gist from reading the code and obscure posts (there are no threads that directly discuss what Maid is), but I’m still not fully certain of what I’ve read.
If anyone’s familiar with Maid/Janitor, I would like some confirmation, correction of misconceptions or some knowledge on these objects. Apparently they’re very useful and I’d like to solidify my knowledge before I step further.
I could just be overthinking it altogether or not thinking properly. The answer could be right on this thread and I skimmed over it.
What I have right now:
- An object intended to do clean up for any object.
What I don’t understand:
-
“This implementation covers all use cases, as it doesn’t force you to rely on naive typechecking to guess how an instance should be cleaned up. Instead, the developer may specify any behavior for any object.”
- From reading the code, it seems that you can pass a string specifying the method to remove a Janitor indice by, which defaults to Destroy. That string is used as an indice to the object for a method call (e.g.
Instance["Destroy"](Instance)
).
- From reading the code, it seems that you can pass a string specifying the method to remove a Janitor indice by, which defaults to Destroy. That string is used as an indice to the object for a method call (e.g.
-
What’s it’s purpose?
What I have right now:
- An object intended to do clean up for any object
What I don’t understand:
-
GiveTask and setting an indice in the Maid seem to do the same thing? What’s the difference?
- From a bit of reading, it seems that GiveTask just adds a certain value you pass to a table. Is it named this way for conventional reasons and to fit in with the class name of “Maid”?
DevForum
What I got from reading posts:
-
Acreol: “
A temporary fix until Roblox actually patches it could be tostore all of the connections to Player signals in a table and disconnect them all when the player leaves the game (basically a maid that cleans on player removing)” -
DataBrain: “I would create a helper table, or maybe even a simple Maid class where you can collect connections, instances, etc. that need to be removed at a later time.”
-
Quenty: " Using a maid object to connect to events and then cleanup state is really nice, something that would generally require another object if you didn’t have this abstraction."
- (What is an abstraction?)
Cheers for any replies.