--[=[
	Cleans up the service bag and all services that have been
	initialized in the service bag.
]=]

function ServiceBag:Destroy()
	local super = getmetatable(ServiceBag)

	self._destroying:Fire()

	local services = self._services
	local key, service = next(services)
	while service ~= nil do
		services[key] = nil

		if not (self._serviceTypesToInitializeSet and self._serviceTypesToInitializeSet[key]) then
			task.spawn(function()
				if service.Destroy then
					service:Destroy()
				end
			end)
		end
		key, service = next(services)
	end

	super.Destroy(self)
end

return ServiceBag
