function Rx.distinct()return function(M)assert(Observable.isObservable(M),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(r)local f=UNSET_VALUE return M:Subscribe(function(M)if f==M then return end f=M r:Fire(f)end,r:GetFailComplete())end)end end

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

		return Observable.new(function(sub)
			local last = UNSET_VALUE

			return source:Subscribe(
				function(value)
					-- TODO: Support tuples
					if last == value then
						return
					end

					last = value
					sub:Fire(last)
				end,
				sub:GetFailComplete()
			)
		end)
	end
end
