function RxBrioUtils.completeOnDeath(Z,w)assert(Brio.isBrio(Z))assert(Observable.isObservable(w))return Observable.new(function(z)if Z:IsDead()then z:Complete()return end local A=Z:ToMaid()A:GiveTask(function()z:Complete()end)A:GiveTask(w:Subscribe(z:GetFireFailComplete()))return A end)end
--[=[
	Completes the observable on death

	@param brio Brio
	@param observable Observable<T>
	@return Observable<T>
]=]
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
