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
Osyris
OsyrisOP3y ago
@Dexxter You can post it here, I'll edit the title/message
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Osyris
OsyrisOP3y ago
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> here
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
roblox-ts
roblox-ts3y ago
Playground link
Posted by <@120766508702892033>
Osyris
OsyrisOP3y ago
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
Osyris
OsyrisOP3y ago
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.
Osyris
OsyrisOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?