Im wondering if there is an equivalent to arrow functions in verse. The use case I have is I want to call SpawnerDevice.SpawnedEvent.Subscribe(OnPlayerSpawned) but I want to add an additional parameter into the OnPlayerSpawned function call. It’d look something like this:
Hi,
it seems you’re referring to lambdas, which are currently not available in Verse.
Two common options to solve this are:
Custom event handler class
Use a custom event handler class which holds a reference to the sender device and a function with the correct signature for the type of event you’re handling. Then make an instance of that handler class, save the sender and subscribe the event to the custom handler’s function.
For example, with a button_device:
Create an async function that acts as a handler and uses the XEvent.Await() pattern. This is usually better for single-time activations (since you don’t have to unsubscribe the event or maintain state).
Again, with a button_device and support for multiple activations: