function RxBrioUtils.onlyLastBrioSurvives()return function(A)return Observable.new(function(S)local x=Maid.new()x:GiveTask(A:Subscribe(function(A)if not Brio.isBrio(A)then warn(("\091\082\120\066\114\105\111\085\116\105\108\115\046\111\110\108\121\076\097\115\116\066\114\105\111\083\117\114\118\105\118\101\115\093 - \078\111\116 \097 \098\114\105\111\044 \037\113"):format(tostring(A)))x._lastBrio=nil S:Fail("\078\111\116 \097 \098\114\105\111")return end local v=BrioUtils.clone(A)x._lastBrio=v S:Fire(v)end,S:GetFailComplete()))return x end)end end

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

			maid:GiveTask(source:Subscribe(function(brio)
				if not Brio.isBrio(brio) then
					warn(("[RxBrioUtils.onlyLastBrioSurvives] - Not a brio, %q"):format(tostring(brio)))
					maid._lastBrio = nil
					sub:Fail("Not a brio")
					return
				end

				local wrapperBrio = BrioUtils.clone(brio)
				maid._lastBrio = wrapperBrio

				sub:Fire(wrapperBrio)
			end, sub:GetFailComplete()))

			return maid
		end)
	end
end
