local Rx = require 'Rx'

local AsyncSubject = Rx.AsyncSubject

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

return function(self, selector)

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

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

end
