class Rx::ObserverBase

Base class for all Observer implementations

Public Class Methods

new(config) click to toggle source
# File lib/rx/core/observer.rb, line 74
def initialize(config)
  @config = config
  @stopped = false
end

Public Instance Methods

dispose() click to toggle source
# File lib/rx/core/observer.rb, line 84
def dispose
  unsubscribe
end
fail(error) click to toggle source
# File lib/rx/core/observer.rb, line 110
def fail(error) 
  unless @stopped
    @stopped = true
    @config.on_error_action.call error
    return true
  end
  return false
end
on_completed() click to toggle source

Notifies the observer of the end of the sequence.

# File lib/rx/core/observer.rb, line 103
def on_completed
  unless @stopped
    @stopped = true
    @config.on_completed_action.call
  end
end
on_error(error) click to toggle source

Notifies the observer that an exception has occurred.

# File lib/rx/core/observer.rb, line 94
def on_error(error)
  raise 'Error cannot be nil' unless error
  unless @stopped
    @stopped = true
    @config.on_error_action.call error
  end
end
on_next(value) click to toggle source

Notifies the observer of a new element in the sequence.

# File lib/rx/core/observer.rb, line 89
def on_next(value)
  @config.on_next_action.call value unless @stopped
end
unsubscribe() click to toggle source

Unsubscribes from the current observer causing it to transition to the stopped state.

# File lib/rx/core/observer.rb, line 80
def unsubscribe
  @stopped = true
end