Skip to content

Commit 0c903e4

Browse files
committed
Add blank Context#on_event method
to be able to add custom code invocation on events like `:terminated`, `:resumed`, `anError`
1 parent 85e4fab commit 0c903e4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/concurrent/actor/behaviour.rb

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Concurrent
22
module Actor
33

44
# TODO document dependencies
5-
# TODO callbacks to context
65
module Behaviour
76
MESSAGE_PROCESSED = Object.new
87

lib/concurrent/actor/behaviour/executes_context.rb

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ class ExecutesContext < Abstract
55
def on_envelope(envelope)
66
context.on_envelope envelope
77
end
8+
9+
def on_event(event)
10+
context.on_event(event)
11+
super event
12+
end
813
end
914
end
1015
end

lib/concurrent/actor/context.rb

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def on_message(message)
2828
raise NotImplementedError
2929
end
3030

31+
# override to add custom code invocation on events like `:terminated`, `:resumed`, `anError`.
32+
def on_event(event)
33+
end
34+
3135
# @api private
3236
def on_envelope(envelope)
3337
@envelope = envelope

0 commit comments

Comments
 (0)