Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Can we define, emit and listen to Custom Events?Forum ↗

Can we define, emit and listen to Custom Events?

App Development3 posts344 views6 likesLast activity Nov 2020
AN
anuragp090OP
Nov 2020 1

Hi,
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 2020 3

There 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 2020 2

Thanks @bernhard for the quick response. I will try this approach.

← Back to Discussions