# Source URL: https://dev.epicgames.com/community/snippets/a7JD/fortnite-subscribable-utils
# Local doc: epic-docs/community/snippets/a7JD/fortnite-subscribable-utils.md
# Registers `Callback` to `Subscribable` with `Context` passed as an additional argument.
(Subscribable:subscribable(payload) where payload:type).SubscribeWith<public>(
Callback:tuple(payload, context) -> void,
Context:context where context:type
)<transacts>:cancelable =
Wrapper := wrapper_sub(payload, context):
Callback := Callback,
Context := Context
return Subscribable.Subscribe(Wrapper.InvokeCallback)
# Registers `Callback` to parameterless `Subscribable` with `Context` passed as the only argument.
(Subscribable:subscribable(tuple())).SubscribeEmptyWith<public>(
Callback:context -> void,
Context:context where context:type
)<transacts>:cancelable =
Wrapper := wrapper_sub_empty(context):
Callback := Callback,
Context := Context
return Subscribable.Subscribe(Wrapper.InvokeCallback)
# Registers a suspending `Callback` to `Subscribable`. Each signal spawns a new task.
(Subscribable:subscribable(payload) where payload:type).SubscribeSuspends<public>(
Callback:type{_(:payload)<suspends>:void}
)<transacts>:cancelable =
Wrapper:wrapper_sub_suspends_basic(payload) = wrapper_sub_suspends_basic(payload):
Callback := Callback
return Subscribable.Subscribe(Wrapper.InvokeCallback)
# Registers a suspending `Callback` to `Subscribable` with `Context` passed as an additional argument. Each signal spawns a new task.
(Subscribable:subscribable(payload) where payload:type).SubscribeSuspendsWith<public>(
Callback:type{_(:tuple(payload, context))<suspends>:void},
Verse Library
verse
01 Snippet
Helper functions to attach callbacks with context or suspension to devices and event systems.
extracted-snippets/community/snippets/a7JD/fortnite-subscribable-utils/01-snippet.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.