# Events in Verse Pattern

**URL:** <https://forums.unrealengine.com/t/events-in-verse-pattern/1166748>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [May 15, 2023, 5:58pm UTC](https://forums.unrealengine.com/t/events-in-verse-pattern/1166748 "2023-05-15T17:58:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alk3ovation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alk3ovation](https://forums.unrealengine.com/u/alk3ovation)\
**Post date:** [May 15, 2023, 5:58pm UTC](https://forums.unrealengine.com/t/events-in-verse-pattern/1166748/1 "2023-05-15T17:58:35Z")

</div>

Hello! I wanted to confirm that this pattern I’m using in Verse is the expected pattern to use for events and to see if there are any other people using events differently.

I’m used to be able to create events more similar to the way most of the “subscribable” events are on the Epic created Verse classes. You subscribe to an event and when it fires, your function gets called. However, I couldn’t find an example of creating and triggering your own “subscribable”. The docs make it sound like your class needs to implement “signalable” and “subscribable” but it’s unclear to me how you create specific events that way. However, I did find the “event” object and I have started to use that.

The event object looks to be created for async contexts and the pattern I started using is as follows

```auto
HandlerFunction<private>()<suspends> : void = 
        loop:
            EventPayload : event_payload = AnotherObject.CustomEvent.Await()

            Logger.Print("CustomEvent Tirggered")
           # DO something with the payload

 OnBegin<override>()<suspends>:void=        
        #init logic
        spawn:
            HandlerFunction()

```

If I need multiple event handlers in the class, I spawn them each individually. This doesn’t feel quite right but it works, so I wanted to see how others are using events and if anyone has figured out the “subscribable” pattern.

Thanks!

---

<div class="post-metadata">

**Author:** ![Mapshot\_Agency](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mapshot_agency/32/700660_2.png) [@Mapshot\_Agency](https://forums.unrealengine.com/u/Mapshot_Agency)\
**Post date:** [May 16, 2023, 7:24am UTC](https://forums.unrealengine.com/t/events-in-verse-pattern/1166748/2 "2023-05-16T07:24:47Z")

</div>

For now, it looks like we’re not able to implement our own “listenable” or “subscribable” interfaces. This post already covered this topic with a workaround.

> [@How do you implement your own listenable in Verse?](https://forums.unrealengine.com/t/how-do-you-implement-your-own-listenable-in-verse/832267/5):
>
> Hello, you can’t initialize a listenable interface inside a class. For now, I recommend exposing an event like the CountdownEndedEvent (for example OnTimerIteration/OnTick) that lets users of the class Await it. You’d then Signal the event when needed. I haven’t played around with it much, but maybe something like this could also be helpful to you: # In this case the functions we accept should take one string parameter and return void. my\_fun := type{\_(:string):void} my\_subscribable := clas…

Hope this helps!

---

<div class="post-metadata">

**Author:** ![alk3ovation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alk3ovation](https://forums.unrealengine.com/u/alk3ovation)\
**Post date:** [May 16, 2023, 7:36pm UTC](https://forums.unrealengine.com/t/events-in-verse-pattern/1166748/3 "2023-05-16T19:36:42Z")

</div>

That is helpful, thanks! I think the array of function objects makes sense. I thought there might be a way to officially utilize the interfaces they use on internal classes though.

I guess the follow question I would have is that epic recommends against using “spawn” if you can. In this case, I don’t think I could avoid it. Is there any problem with having a bunch of spawned handlers “awaiting” a bunch of events? Performance or memory wise?

---

<div class="post-metadata">

**Author:** ![Mapshot\_Agency](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mapshot_agency/32/700660_2.png) [@Mapshot\_Agency](https://forums.unrealengine.com/u/Mapshot_Agency)\
**Post date:** [May 17, 2023, 7:19am UTC](https://forums.unrealengine.com/t/events-in-verse-pattern/1166748/4 "2023-05-17T07:19:13Z")

</div>

I’m not an expert on memory but Epic also states in their documentation that sometimes there’s just no way around using a “spawn”. They even say that sometimes it’s the best option. So my guess would be that as long as you think everything through and you don’t use hundreds of spawns, you’ll be fine.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 18, 2023, 7:20am UTC](https://forums.unrealengine.com/t/events-in-verse-pattern/1166748/5 "2023-05-18T07:20:06Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
