function RxBrioUtils.completeOnDeath(g,G)assert(Brio.isBrio(g))assert(Observable.isObservable(G))return Observable.new(function(F)if g:IsDead()then F:Complete()return end local C=g:ToMaid()C:GiveTask(function()F:Complete()end)C:GiveTask(G:Subscribe(F:GetFireFailComplete()))return C end)end

function RxBrioUtils.completeOnDeath(brio, observable)
	assert(Brio.isBrio(brio))
	assert(Observable.isObservable(observable))

	return Observable.new(function(sub)
		if brio:IsDead() then
			sub:Complete()
			return
		end

		local maid = brio:ToMaid()

		maid:GiveTask(function()
			sub:Complete()
		end)
		maid:GiveTask(observable:Subscribe(sub:GetFireFailComplete()))

		return maid
	end)
end
