function Rx.defer(J)return Observable.new(function(p)local A local G,W=pcall(function()A=J()end)if not G then p:Fail(W)return end if not Observable.isObservable(A)then p:Fail("\078\111\116 \097\110 \111\098\115\101\114\118\097\098\108\101")return end return A:Subscribe(p:GetFireFailComplete())end)end

function Rx.defer(observableFactory)
	return Observable.new(function(sub)
		local observable
		local ok, err = pcall(function()
			observable = observableFactory()
		end)

		if not ok then
			sub:Fail(err)
			return
		end

		if not Observable.isObservable(observable) then
			sub:Fail("Not an observable")
			return
		end

		return observable:Subscribe(sub:GetFireFailComplete())
	end)
end
