function RxBrioUtils.switchToBrio()return function(q)return Observable.new(function(U)local y=Maid.new()y:GiveTask(q:Subscribe(function(q,...)if Brio.isBrio(q)then if q:IsDead()then y._last=nil return end local M=q:ToMaid()local A=Brio.new(q:GetValue())M:GiveTask(A)y._last=M U:Fire(A)else local M=Brio.new(q,...)y._last=M U:Fire(M)end end,U:GetFailComplete()))return y end)end end return RxBrioUtils

function RxBrioUtils.switchToBrio()
	return function(source)
		return Observable.new(function(sub)
			local topMaid = Maid.new()

			topMaid:GiveTask(source:Subscribe(function(result, ...)
				if Brio.isBrio(result) then
					if result:IsDead() then
						topMaid._last = nil
						return
					end

					local maid = result:ToMaid()
					local newBrio = Brio.new(result:GetValue())
					maid:GiveTask(newBrio)

					topMaid._last = maid
					sub:Fire(newBrio)
				else
					local newBrio = Brio.new(result, ...)

					topMaid._last = newBrio
					sub:Fire(newBrio)
				end
			end, sub:GetFailComplete()))

			return topMaid
		end)
	end
end


return RxBrioUtils
