local Rx = require 'Rx'

local Subject = Rx.Subject

--------------------------------------------------------------------------------

return function(self, selector)

    if selector ~= nil and type(selector) ~= 'function' then
        error("Rx.Observable:publish: selector must be a function or nil")
    end

    return self:multicast(function()
        return Subject()
    end, selector)

end
