function Rx.throttleDefer()return function(x)assert(Observable.isObservable(x),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(B)local t=Maid.new()local W t:GiveTask(x:Subscribe(function(...)if not W then W=table.pack(...)task.defer(function()local x=W W=nil if B:IsPending()then B:Fire(table.unpack(x,1,x.n))end end)else W=table.pack(...)end end,B:GetFailComplete()))return t end)end end return Rx

function Rx.throttleDefer()
	return function(source)
		assert(Observable.isObservable(source), "Bad observable")

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

			local lastResult

			maid:GiveTask(source:Subscribe(function(...)
				if not lastResult then
					lastResult = table.pack(...)

					-- Queue up our result
					task.defer(function()
						local current = lastResult
						lastResult = nil

						if sub:IsPending() then
							sub:Fire(table.unpack(current, 1, current.n))
						end
					end)
				else
					lastResult = table.pack(...)
				end
			end, sub:GetFailComplete()))

			return maid
		end)
	end
end

return Rx
