function Rx.defaultsTo(p)return function(g)assert(Observable.isObservable(g),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(F)local s=Maid.new()local r=false s:GiveTask(g:Subscribe(function(...)r=true F:Fire(...)end,F:GetFailComplete()))if not r then F:Fire(p)end return s end)end end

function Rx.defaultsTo(value)
	return function(source)
		assert(Observable.isObservable(source), "Bad observable")

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

			local fired = false

			maid:GiveTask(source:Subscribe(
				function(...)
					fired = true
					sub:Fire(...)
				end,
				sub:GetFailComplete()))

			if not fired then
				sub:Fire(value)
			end

			return maid
		end)
	end
end
