Class: Rooibos::Message::Canceled
- Inherits:
-
Data
- Object
- Data
- Rooibos::Message::Canceled
- Includes:
- Predicates
- Defined in:
- lib/rooibos/message/canceled.rb
Overview
Cancellation notification from a canceled command.
Long-running commands respond to cancellation cooperatively. When the runtime signals cancellation, the command finishes current work and sends this message.
Pattern match on Canceled in your update function to clean up state, stop animations, or acknowledge the cancellation.
Use it to handle timer cancellations, aborted HTTP requests, or stopped background processes.
Example
Update = ->(, model) {
case
in { type: :canceled, command: }
# Timer was canceled, clear the notification
model.with(notification: nil)
in Message::Canceled
# Generic cancellation handling
model
end
}
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#canceled? ⇒ Boolean
(also: #cancelled?)
Returns
truefor cancellation messages. -
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
Methods included from Predicates
#==, #method_missing, #respond_to_missing?, #to_sym
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rooibos::Message::Predicates
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command
34 35 36 |
# File 'lib/rooibos/message/canceled.rb', line 34 def command @command end |
Instance Method Details
#canceled? ⇒ Boolean Also known as: cancelled?
Returns true for cancellation messages.
38 39 40 |
# File 'lib/rooibos/message/canceled.rb', line 38 def canceled? true end |
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
Returns a hash with type and command.
46 47 48 |
# File 'lib/rooibos/message/canceled.rb', line 46 def deconstruct_keys(_keys) { type: :canceled, command: } end |