Can we define, emit and listen to Custom Events?

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

1 Like

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.

3 Likes

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

2 Likes