Class: QML::Reactive::Signals::SelectSignal

Inherits:
ChainedSignal show all
Defined in:
lib/qml/reactive/signals/select_signal.rb

Instance Attribute Summary

Attributes inherited from QML::Reactive::Signal

#arity

Instance Method Summary collapse

Methods inherited from QML::Reactive::Signal

#connect, #connection_count, #disconnect, #emit, #map, #merge, #parameters, #select, #spy, #to_proc

Constructor Details

#initialize(source, pred) ⇒ SelectSignal

Returns a new instance of SelectSignal.



7
8
9
10
11
# File 'lib/qml/reactive/signals/select_signal.rb', line 7

def initialize(source, pred)
  super(source.parameters.map(&:last))
  @source = source
  @pred = pred
end

Instance Method Details

#connect_to_sourcesObject



13
14
15
16
17
# File 'lib/qml/reactive/signals/select_signal.rb', line 13

def connect_to_sources
  @source.connect do |*args|
    emit(*args) if @pred.call(*args)
  end
end