Module: Rx::Notification

Included in:
OnCompletedNotification, OnErrorNotification, OnNextNotification
Defined in:
lib/rx/core/notification.rb

Overview

Represents a notification to an observer.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_on_completedObject

Creates an object that represents an on_completed notification to an observer.



40
41
42
# File 'lib/rx/core/notification.rb', line 40

def create_on_completed
  OnCompletedNotification.new
end

.create_on_error(error) ⇒ Object

Creates an object that represents an on_error notification to an observer.



35
36
37
# File 'lib/rx/core/notification.rb', line 35

def create_on_error(error)
  OnErrorNotification.new error
end

.create_on_next(value) ⇒ Object

Creates an object that represents an on_next notification to an observer.



30
31
32
# File 'lib/rx/core/notification.rb', line 30

def create_on_next(value)
  OnNextNotification.new value
end

Instance Method Details

#has_value?Boolean

Determines whether this notification has a value.

Returns:

  • (Boolean)


62
63
64
# File 'lib/rx/core/notification.rb', line 62

def has_value?
  false
end

#on_completed?Boolean

Determines whether this is an on_completed notification.

Returns:

  • (Boolean)


57
58
59
# File 'lib/rx/core/notification.rb', line 57

def on_completed?
  @kind == :on_completed
end

#on_error?Boolean

Determines whether this is an on_error notification.

Returns:

  • (Boolean)


52
53
54
# File 'lib/rx/core/notification.rb', line 52

def on_error?
  @kind == :on_error
end

#on_next?Boolean

Determines whether this is an on_next notification.

Returns:

  • (Boolean)


47
48
49
# File 'lib/rx/core/notification.rb', line 47

def on_next?
  @kind == :on_next
end

#to_observable(scheduler = ImmediateScheduler.instance) ⇒ Object

Returns an observable sequence with a single notification.



67
68
69
70
71
72
73
74
# File 'lib/rx/core/notification.rb', line 67

def to_observable(scheduler = ImmediateScheduler.instance)
  AnonymousObservable.new do |observer|
    scheduler.schedule lambda {
      accept observer
      observer.on_completed if on_next?
    }
  end
end