function RxBrioUtils.reemitLastBrioOnDeath()return function(A)return Observable.new(function(O)local s=Maid.new()s:GiveTask(A:Subscribe(function(A)s._conn=nil if not Brio.isBrio(A)then warn(("\091\082\120\066\114\105\111\085\116\105\108\115\046\114\101\101\109\105\116\076\097\115\116\066\114\105\111\079\110\068\101\097\116\104\093 - \078\111\116 \097 \098\114\105\111\044 \037\113"):format(tostring(A)))O:Fail("\078\111\116 \097 \098\114\105\111")return end if A:IsDead()then O:Fire(A)return end s._conn=(A:GetDiedSignal()):Connect(function()O:Fire(A)end)O:Fire(A)end,function(...)O:Fail(...)end,function(...)O:Complete(...)end))return s end)end end

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

			maid:GiveTask(source:Subscribe(
				function(brio)
					maid._conn = nil

					if not Brio.isBrio(brio) then
						warn(("[RxBrioUtils.reemitLastBrioOnDeath] - Not a brio, %q"):format(tostring(brio)))
						sub:Fail("Not a brio")
						return
					end

					if brio:IsDead() then
						sub:Fire(brio)
						return
					end

					-- Setup conn!
					maid._conn = brio:GetDiedSignal():Connect(function()
						sub:Fire(brio)
					end)

					sub:Fire(brio)
				end,
				function(...)
					sub:Fail(...)
				end,
				function(...)
					sub:Complete(...)
				end))

			return maid
		end)
	end
end
