Class: Rooibos::Message::Canceled

Inherits:
Data
  • Object
show all
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 = ->(message, model) {
  case message
  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

Instance Method Summary collapse

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

#commandObject (readonly)

Returns the value of attribute command

Returns:

  • (Object)

    the current value of 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.

Returns:

  • (Boolean)


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