function Rx.endWith(z)return function(h)assert(Observable.isObservable(h),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(U)local k=Maid.new()k:GiveTask(h:Subscribe(function(...)U:Fire(...)end,function(...)for z,h in pairs(z)do U:Fire(h)end U:Fail(...)end),function()for z,h in pairs(z)do U:Fire(h)end U:Complete()end)return k end)end end
--[=[
	Ends the observable with these values before cancellation
	https://www.learnrxjs.io/learn-rxjs/operators/combination/endwith

	@param values { T }
	@return (source: Observable) -> Observable
]=]
function Rx.endWith(values)
	return function(source)
		assert(Observable.isObservable(source), "Bad observable")

		return Observable.new(function(sub)
			local maid = Maid.new()

			maid:GiveTask(
				source:Subscribe(function(...)
					sub:Fire(...)
				end, function(...)
					for _, item in pairs(values) do
						sub:Fire(item)
					end
					sub:Fail(...)
				end),
				function()
					for _, item in pairs(values) do
						sub:Fire(item)
					end
					sub:Complete()
				end
			)

			return maid
		end)
	end
end
