table.insert() equivalent to TypeScript
From @Dexxter :
How do I insert into a table an RBXScriptConnection? And make a loop to disconnect those connections?
11 Replies
@Dexxter You can post it here, I'll edit the title/message
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
roblox-ts separates the idea of a "table" into four distinct concepts:
1.
object
which is like { a = 1, b = 2 }
. Members statically declared, never changing.
2. Array<T>
which is like { 1, 2, 3 }
. Table used as an array, keys are increasing integers starting at 1
3. Map<K, V>
which is like { ["foo"] = "bar" }
or map["foo"] = "bar"
. Keys/values are arbitrary and may or may not exist
4. Set<T>
which is like { foo = true }
or set["foo"] = true
. Keys are arbitrary, values are either true
or don't exist.
You're looking to make an Array<T>
hereUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
Playground link
Posted by <@120766508702892033>
Here's an example in the playground of how you might do this
but FWIW, it sounds like you might be interested in
@rbxts/maid
npm
@rbxts/maid
Quenty's Maid class with types!. Latest version: 1.0.0-ts.1, last published: 2 years ago. Start using @rbxts/maid in your project by running
npm i @rbxts/maid
. There are 7 other projects in the npm registry using @rbxts/maid.Maid is a library where you can give it a bunch of things and then later tell it to clean up those things
including RBXScriptConnections
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Quenty wrote a great article about it here: https://medium.com/roblox-development/how-to-use-a-maid-class-on-roblox-to-manage-state-651bf74de98b
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View