Module: Legion::Extensions::React

Extended by:
Core
Defined in:
lib/legion/extensions/react.rb,
lib/legion/extensions/react/version.rb,
lib/legion/extensions/react/rule_engine.rb,
lib/legion/extensions/react/runners/react.rb,
lib/legion/extensions/react/helpers/constants.rb,
lib/legion/extensions/react/reaction_dispatcher.rb,
lib/legion/extensions/react/helpers/loop_breaker.rb,
lib/legion/extensions/react/helpers/event_matcher.rb,
lib/legion/extensions/react/actors/event_subscriber.rb

Defined Under Namespace

Modules: Actor, Helpers, Runners Classes: ReactionDispatcher, RuleEngine

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.data_required?Boolean



17
18
19
# File 'lib/legion/extensions/react.rb', line 17

def data_required?
  false
end

.subscribe!Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/legion/extensions/react.rb', line 21

def subscribe!
  return unless defined?(Legion::Events)

  @subscription ||= Legion::Events.on('*') do |event|
    next if event[:event].to_s.start_with?('react.')

    Runners::React.handle_event(event: event)
  rescue StandardError => e
    Legion::Logging.warn "[React] event handler error: #{e.message}" if defined?(Legion::Logging)
  end
end

.unsubscribe!Object



33
34
35
36
37
38
# File 'lib/legion/extensions/react.rb', line 33

def unsubscribe!
  return unless @subscription && defined?(Legion::Events)

  Legion::Events.off('*', @subscription)
  @subscription = nil
end