Can we define, emit and listen to Custom Events?
App Development3 posts331 views6 likesLast activity Nov 2020
AN
anuragp090OP
Nov 2020Hi,
I am curious to know if DAML has provision to define, emit and listen to custom events?
In other words is it possible to emit custom events inside a choice?
Thanks
BE
bernhard
Nov 2020There is no special inbuilt for custom events as every choice exercise is an event. So if you want to emit an event, you can just create a choice without an effect:
controller (signatory this) can
nonconsuming MyEvent : ()
with
message : Text
do
return ()
If you exercise that, all you’ll get is an extra node on the transaction tree that you can react to.
AN
anuragp090
Nov 2020Thanks @bernhard for the quick response. I will try this approach.