Class: Synapse::Command::CommandBus Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/command/command_bus.rb

Overview

This class is abstract.

Represents a mechanism for dispatching commands to their appropriate handlers

Command handlers can subscribe and unsubscribe to different command types. Only a single handler can be subscribed for a command type at one time.

Implementations can choose to dispatch commands in the calling thread or in another thread.

Direct Known Subclasses

SimpleCommandBus

Instance Method Summary collapse

Instance Method Details

#dispatch(command) ⇒ undefined

This method is abstract.

Dispatches the given command to the handler subscribed to its type

Parameters:

Returns:

  • (undefined)


17
# File 'lib/synapse/command/command_bus.rb', line 17

def dispatch(command); end

#dispatch_with_callback(command, callback) ⇒ undefined

This method is abstract.

Dispatches the given command to the handler subscribed to its type and notifies the given callback of the outcome of the dispatch

Parameters:

Returns:

  • (undefined)


26
# File 'lib/synapse/command/command_bus.rb', line 26

def dispatch_with_callback(command, callback); end

#subscribe(command_type, handler) ⇒ undefined

Subscribes the given handler to the given command type, replacing the currently subscribed handler, if any.

Parameters:

Returns:

  • (undefined)


34
# File 'lib/synapse/command/command_bus.rb', line 34

def subscribe(command_type, handler); end

#unsubscribe(command_type, handler) ⇒ undefined

Unsubscribes the given handler from the given command type, if it is currently subscribed to the given command type.

Parameters:

Returns:

  • (undefined)


42
# File 'lib/synapse/command/command_bus.rb', line 42

def unsubscribe(command_type, handler); end