local s=require(script.Parent.Roact)local u=require(script.Parent.t)local c=s.Component:extend("\069\118\101\110\116\067\111\110\110\101\099\116\105\111\110")c.validateProps=u.strictInterface({Event=u.RBXScriptSignal,Function=u.callback})function c.init(s)s.connection=nil end function c.didMount(s)s.connection=s.props.Event:Connect(s.props.Function)end function c.render()return nil end function c.didUpdate(u,s)if u.props.Event~=s.Event or u.props.Function~=s.Function then u.connection:Disconnect()u.connection=u.props.Event:Connect(u.props.Function)end end function c.willUnmount(s)s.connection=s.connection:Disconnect()end return c
-- @license https://github.com/Kampfkarren/hoarcekat/blob/master/LICENSE.md
-- @source https://github.com/Kampfkarren/hoarcekat/blob/master/src/Components/EventConnection.lua

local Roact = require(script.Parent.Roact)
local t = require(script.Parent.t)

local EventConnection = Roact.Component:extend("EventConnection")
EventConnection.validateProps = t.strictInterface({
	Event = t.RBXScriptSignal,
	Function = t.callback,
})

function EventConnection:init()
	self.connection = nil
end

function EventConnection:didMount()
	self.connection = self.props.Event:Connect(self.props.Function)
end

function EventConnection.render()
	return nil
end

function EventConnection:didUpdate(oldProps)
	if self.props.Event ~= oldProps.Event or self.props.Function ~= oldProps.Function then
		self.connection:Disconnect()
		self.connection = self.props.Event:Connect(self.props.Function)
	end
end

function EventConnection:willUnmount()
	self.connection = self.connection:Disconnect()
end

return EventConnection
