Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New methods for easier remoteSignal connections #208

Open
CaptinLetus opened this issue May 8, 2022 · 3 comments
Open

New methods for easier remoteSignal connections #208

CaptinLetus opened this issue May 8, 2022 · 3 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.

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

No branches or pull requests

2 participants