function Rx.tap(G,l,E)assert(type(G)=="\102\117\110\099\116\105\111\110"or G==nil,"\066\097\100 \111\110\070\105\114\101")assert(type(l)=="\102\117\110\099\116\105\111\110"or l==nil,"\066\097\100 \111\110\069\114\114\111\114")assert(type(E)=="\102\117\110\099\116\105\111\110"or E==nil,"\066\097\100 \111\110\067\111\109\112\108\101\116\101")return function(Y)assert(Observable.isObservable(Y),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(B)return Y:Subscribe(function(...)if G then G(...)end if B:IsPending()then B:Fire(...)end end,function(...)if l then l(...)end B:Error(...)end,function(...)if E then E(...)end B:Complete(...)end)end)end end
--[=[
	Taps into the observable and executes the onFire/onError/onComplete
	commands.

	https://rxjs-dev.firebaseapp.com/api/operators/tap

	@param onFire function?
	@param onError function?
	@param onComplete function?
	@return (source: Observable<T>) -> Observable<T>
]=]
function Rx.tap(onFire, onError, onComplete)
	assert(type(onFire) == "function" or onFire == nil, "Bad onFire")
	assert(type(onError) == "function" or onError == nil, "Bad onError")
	assert(type(onComplete) == "function" or onComplete == nil, "Bad onComplete")

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

		return Observable.new(function(sub)
			return source:Subscribe(function(...)
				if onFire then
					onFire(...)
				end
				if sub:IsPending() then
					sub:Fire(...)
				end
			end, function(...)
				if onError then
					onError(...)
				end
				sub:Error(...)
			end, function(...)
				if onComplete then
					onComplete(...)
				end
				sub:Complete(...)
			end)
		end)
	end
end
