function RxBrioUtils.toEmitOnDeathObservable(Z,H)if not Brio.isBrio(Z)then return Rx.of(Z)else return Observable.new(function(S)if Z:IsDead()then S:Fire(H)S:Complete()else S:Fire(Z:GetValue())return(Z:GetDiedSignal()):Connect(function()S:Fire(H)S:Complete()end)end end)end end
--[=[
	Transforms the brio into an observable that emits the initial value of the brio, and then another value on death
	@param brio Brio<T> | T
	@param emitOnDeathValue U
	@return Observable<T | U>
]=]
function RxBrioUtils.toEmitOnDeathObservable(brio, emitOnDeathValue)
	if not Brio.isBrio(brio) then
		return Rx.of(brio)
	else
		return Observable.new(function(sub)
			if brio:IsDead() then
				sub:Fire(emitOnDeathValue)
				sub:Complete()
			else
				sub:Fire(brio:GetValue())
				return brio:GetDiedSignal():Connect(function()
					sub:Fire(emitOnDeathValue)
					sub:Complete()
				end)
			end
		end)
	end
end
