Method: Concurrent::Concern::Observable#add_observer

Defined in:
lib/concurrent-ruby/concurrent/concern/observable.rb

#add_observer(observer = nil, func = :update, &block) ⇒ Object

Adds an observer to this set. If a block is passed, the observer will be created by this method and no other params should be passed.

Parameters:

  • observer (Object) (defaults to: nil)

    the observer to add

  • func (Symbol) (defaults to: :update)

    the function to call on the observer during notification. Default is :update

Returns:

  • (Object)

    the added observer



61
62
63
# File 'lib/concurrent-ruby/concurrent/concern/observable.rb', line 61

def add_observer(observer = nil, func = :update, &block)
  observers.add_observer(observer, func, &block)
end