ConnectionService, a new utility module by me

I am back with another utility module, ConnectionService!

It’s use is to prevent multiple RunService connections

(Supports Client & Server)

(Avoid using many RunService loops with this module)

If you have a question or any optimization possibilities, let me know!
ConnectionService.lua (1.7 KB)
https://create.roblox.com/store/asset/135631117679083

Documentation:

Functions:

Connect (Loop, Name, Function) [

Creates a new connection with [Name/arg 2] as the index and [Function/arg 3] and adds to the RunService Loop from [Loop/arg 1]

],

Disconnect (Loop, Name) [

Disconnects a connection found in the RunService loop from [Loop/arg 1] with the name [Name/arg 2]

],

Create (Loop) [

Creates a new RunService Loop from [Loop/arg 1]

],


Destroy (Loop) [

Destroys an active RunService Loop from [Loop/arg 1]

]



–

Examples: 

local ConnectionService = require(game.ReplicatedStorage.ConnectionService)

ConnectionService.Create("Heartbeat")

ConnectionService.Connect("Heartbeat", "Aitha", function(dt)
	
	warn(dt, "dt")
	
end)

ConnectionService.Connect("Heartbeat", "Fren", function()
	
	warn(tick(), "tick")
	
end)

task.wait(2)

ConnectionService.Disconnect("Heartbeat", "Fren")

Enjoy everyone! take care. (Updates will be made soon!)

If you have any useful utilities for me to make in mind, reply with the idea

3 Likes

The module you’re mentioning isn’t included here. Upload it to Roblox and link it directly rather than pasting this Lua script.

2 Likes

oops! fixed. i pasted something else,

is this resource a ragebait? :face_holding_back_tears:

1 Like

i genuinely tried to make something good, whats the problem?
felt like it would be useful, if you dont find it useful you dont have to use it but what do you mean by its ragebait?
some of you are negative, im just trying to help

no intellisense;
overengineering;
memory leak;
Not user-friendly and is not documented properly;

memory leak evidences:

image
The image upper is so funny actually, since both server and client have different module returned data (and so, different VMs), so server will have unused “ClientConnections” table, and client will have unused “ServerConnections”.

Also correcting functionality on runtime instead of load time is just a waste of computing speed.

image
Incorrect type. “f” actually gets an argument, but you identify it doesn’t have any.

image
Very cool register filling without any logical reasoning behind it + unreadable name. Overengineering.

If it’s not server → it’s client. A very easy logic, isn’t it?


You tried to make it user friendly. However it’s simply taking too much of a responsibility.

Furthermore, you’re creating a new function with same functionality for init (e.g. “Heartbeat” and “PreSimulation” could have use 1 functions, but they create new one).

image
I don’t know what you tried to do here. You don’t cache it at all, much easier is n:Connect(function(dt) ... end

I also don’t know why you tried to make safe code, but did not use xpcall inside of connection call loop to prevent losing other connections.

I also think you made closure based objects, which is a huge memory load.

I believe it might be useful for someone, but it doesn’t change the fact of poor code. Overall: good(?) concept, bad realisation.

3 Likes

thank you for trying to help
i admit that i am not too good at that stuff, i just tried to be honest
now that i see it, my code is not good
im just trying from what i learned

do you got any tips so i can learn? thanks

i have remade it from the ground-up
thank you so much for your help!!

if you still have any problems, let me know. thanks!

(the old version was built from an older concept lol)

1 Like

Hello, it surely became better to read and understand.

However I would like to point one major issue (it opened from lua IDE, that’s why it’s white theme):


You could’ve just parse ... instead of table.unpack(Args) and creating a table, and I advice you to use xpcall since just using pcall won’t output error
(I personally do xpcall(func,warn,...) since passing error function doesn’t output error )

Also you’ve deleted all of types here which is a bit confusing, but alright.

Goodluck in future :+1:

1 Like

for the … stuff, thank you for telling me!
but for xpcall, i didn’t use it cus i didnt need to log any errors
and the types i made this very fast so i forgot to add em lol

thank you for your kind words, goodluck to you too!
(Major bug fixed)

1 Like

New update:

-Added Documentation (probably still unfinished)

-Added part: ‘If you have any useful utilities for me to make in mind, reply with the idea’

if anyone actually uses this, let me know.

(im in a drought of good ideas)

huh i remember 5 people was flamming this post or am i trippin it was a crazy fire

i think it was one of my previous posts? and what do you think of this

i’d say idk i used trove

character character select

what the helly welly is trove

character limit

search up trove rblx util boy

character lim

1 Like

you do not boy me

character minimum