Raise Event Node
Overview
The Raise Event Node allows you to trigger an event from within your graph. This event can be listened for by the host project or by a Wait For Event Node within the same graph. This can be useful for triggering actions in your host application based on the state of your graph, or for synchronizing different parts of your graph.
The node requires an event name and optionally an event data. The event name is used to identify the event when it is raised, and the event data is any additional information that you want to associate with the event.
Toast
In the Rivet application, there is a special event named toast
which can show a toast message. The toast
event accepts a string as its data, which is used as the message of the toast.
- Inputs
- Outputs
- Editor Settings
Inputs
Title | Data Type | Description | Default Value | Notes |
---|---|---|---|---|
Event Name | string | The name of the event to raise. This input is only available if Use Event Name Input is enabled. | (required) | The input will be coerced into a string if it is not a string. |
Data | any | The data to associate with the event. | (empty) | The input will be coerced into the appropriate data type based on the value of the Data . |
Outputs
Title | Data Type | Description | Notes |
---|---|---|---|
Result | any | The data that was associated with the event. | If the Data input is not provided, the Result output will be an empty string ("" ). |
Editor Settings
Setting | Description | Default Value | Use Input Toggle | Input Data Type |
---|---|---|---|---|
Event Name | The name of the event to raise. | (required) | Yes | string |
Use Event Name Input | If enabled, the Event Name can be provided via the Event Name input port. | False | No | N/A |
Example 1: Raise an event with data
- Create a Text Node and set the text to
Hello, world!
. - Create a Raise Event Node and leave the Event Name as
toast
. - Connect the Text Node to the
Data
input of the Raise Event Node. - Run the graph. The
Result
output of the Raise Event Node should beHello, world!
, and a toast message should appear in the Rivet application.
Example 2: Wait for an Chat call to finish before continuing another part of a graph
- Create a Chat Node and give it a prompt using a Text Node such as "What is your name?".
- Create a Raise Event Node, set the Event Name to
chat
, and connect theResponse
output of the Chat Node to theData
input of the Raise Event Node. - In a separate part of the graph, add a Wait For Event Node and set the Event Name to
chat
. - Run the graph. Notice that the Wait For Event Node will not continue until the Chat Node has finished.
Error Handling
The Raise Event Node will error if the Event Name
is not provided.
FAQ
Q: How can I listen for the event that was raised?
A: You can listen for the event in your host application by using the onUserEvent
property of RunGraphOptions. You can also listen for the event within the same graph by using a Wait For Event Node.
Q: Can I pass data with the event?
A: Yes, you can pass data with the event by providing a value to the Data
input. The data can be of any data type.
Q: What happens if I raise an event that no one is listening for?
A: If you raise an event that no one is listening for, nothing will happen. The event will be raised and then immediately discarded.
Q: How is raising event different from an External Call Node?
A: The External Call Node will wait for the external call to complete before continuing, whereas the Raise Event Node will continue immediately after raising the event.