-- Gets a scheduler that schedules work immediately.
-- Note that this is a singleton.

local Rx = require 'Rx'

local Scheduler = Rx.Scheduler

local disposableFixup = Rx.Disposable._fixup

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

local immediateSchedulerClass = Rx.Class('Rx.ImmediateScheduler', {

    Scheduler,
        -- superclass

    schedule = function(self, state, action)

        if action == nil then
            action = state
            state = nil
        end

        return disposableFixup(action(self, state))

    end,

})

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

local immediateSchedulerInstance = immediateSchedulerClass()

return immediateSchedulerInstance
