Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

New methods for easier remoteSignal connections #208

Closed
CaptinLetus opened this issue May 8, 2022 · 4 comments
Closed

New methods for easier remoteSignal connections #208

CaptinLetus opened this issue May 8, 2022 · 4 comments

Comments

@CaptinLetus
Copy link

CaptinLetus commented May 8, 2022

Currently, if a service has a lot of RemtoteSignals, it can make our KnitInit function very long with a bunch of connections.

Here is the current way of doing things:

local SomeService = Knit.CreateService {
	Name = "SomeService";
	Client = {
		SomeEvent = Knit.CreateSignal()
	};
}

function SomeService:KnitInit()
	self.Client.SomeEvent:Connect(function(...)
		self:EventConnection(...)
	end)
end

function SomeService:EventConnection(player, ...)
	print("player sent", ...)
end

It would be nice to have a built-in feature to Knit that would allow us to connect to events like so:

local SomeService = Knit.CreateService {
	Name = "SomeService";
	Client = {
		SomeEvent = Knit.CreateSignal()
	};
}

function SomeService.Client.SomeEvent:Connect(player, ...)
	print("player sent", ...)
end

Similar functions could be made for remote properties as well

@eAi
Copy link

eAi commented May 8, 2022

I don’t think your syntax would quite work - but I think it’d be theoretically possible to make it so you could connect to signals outside KnitInit. I believe that signals aren’t actually created when you call CreateSignal - a placeholder is. This would prevent you connecting to it outside KnitInit - but that could be changed to allow functions to be registered and to copy over the connections when the signal is actually created.

This is something that’s frustrated me too so it would be nice to improve it!

@CaptinLetus
Copy link
Author

Why dont you think the syntax would work?

@ghost
Copy link

ghost commented May 23, 2022

I definitely think there is no need for this, it's just bloat, and leads to syntax inconsistency. You can simply just make a module that wraps your remote signals / properties and use that instead.

@Sleitnick
Copy link
Owner

#248

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants