Class: Rx::ScheduledDisposable
- Inherits:
-
Object
- Object
- Rx::ScheduledDisposable
- Defined in:
- lib/rx/subscriptions/scheduled_subscription.rb
Overview
Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler
Instance Attribute Summary collapse
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
-
#subscription ⇒ Object
readonly
Returns the value of attribute subscription.
Instance Method Summary collapse
-
#initialize(scheduler, subscription) ⇒ ScheduledDisposable
constructor
A new instance of ScheduledDisposable.
-
#unsubscribe ⇒ Object
Unsubscribes the wrapped subscription on the provided scheduler.
-
#unsubscribed? ⇒ Boolean
Gets a value that indicates whether the object is unsubscribed.
Constructor Details
#initialize(scheduler, subscription) ⇒ ScheduledDisposable
Returns a new instance of ScheduledDisposable.
9 10 11 12 13 14 15 |
# File 'lib/rx/subscriptions/scheduled_subscription.rb', line 9 def initialize(scheduler, subscription) raise 'disposable cannot be nil' unless subscription raise 'scheduler cannot be nil' unless scheduler @scheduler = scheduler @subscription = subscription end |
Instance Attribute Details
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
7 8 9 |
# File 'lib/rx/subscriptions/scheduled_subscription.rb', line 7 def scheduler @scheduler end |
#subscription ⇒ Object (readonly)
Returns the value of attribute subscription.
7 8 9 |
# File 'lib/rx/subscriptions/scheduled_subscription.rb', line 7 def subscription @subscription end |
Instance Method Details
#unsubscribe ⇒ Object
Unsubscribes the wrapped subscription on the provided scheduler.
23 24 25 26 27 28 29 30 |
# File 'lib/rx/subscriptions/scheduled_subscription.rb', line 23 def unsubscribe @scheduler.schedule lambda do unless @subscription.nil? @subscription.unsubscribe @subscription = nil end end end |
#unsubscribed? ⇒ Boolean
Gets a value that indicates whether the object is unsubscribed.
18 19 20 |
# File 'lib/rx/subscriptions/scheduled_subscription.rb', line 18 def unsubscribed? @subscription.nil? end |