Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#416 core notification documentation #1120

Merged
merged 18 commits into from
Sep 12, 2024
Merged
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 28 additions & 23 deletions docs/userman/scenario_features/events/examples.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
This page aims at exposing common use cases using Taipy *events*.
Examples of using Taipy event notifications to capture and consume *events*.

# Triggering user interface updates
# Real-Time GUI Updates with Taipy Event Consumers

This example demonstrates the power of event-driven programming in real-world applications. By capturing and processing events, developers can build responsive, dynamic systems that notify users of important changes (such as new scenario creations or data node updates) as they happen. This approach significantly enhances the user experience by providing real-time updates and ensuring users are always informed through an interactive and engaging interface.

jrobinAV marked this conversation as resolved.
Show resolved Hide resolved
This script defines a custom event consumer class `SpecificCoreConsumer`, which listens
for all events published by Taipy Core and triggers GUI notification based on those events.
It includes determining if the event is published from a `Scenario^` entity or `DataNode^` entity
jrobinAV marked this conversation as resolved.
Show resolved Hide resolved
and if the action is `CREATION` or `UPDATE`.

!!! example
```python linenums="1"
{%
include-markdown "./code-example/user-changes-notifier.py"
comments=false
%}
```

```python linenums="1"
{%
include-markdown "./code-example/user-changes-notifier.py"
comments=false
%}
```
This snippet shows how you can capture and process events to notify users whenever
a new scenario is created, or a data node's value is updated.
For more details, see the [registration](understanding-topics.md) page.

This snippet shows a how you can capture and process events to notify user whenever
a new scenario is created or the value of a data node is updated.
For more details, see the [registration](understanding-notifier-register.md) page.
# External API triggered with Taipy Event Consumers

# Triggering External API Calls
This example illustrates leveraging event-driven programming to monitor and respond to specific event types. By implementing a custom event consumer, `JobFailureCoreConsumer`, developers can easily trigger external API calls based on specific job status updates. This approach ensures that critical job status changes are promptly communicated to external systems, enhancing the application's monitoring and integration with third-party systems.

jrobinAV marked this conversation as resolved.
Show resolved Hide resolved
This script defines a custom event consumer class `JobFailureCoreConsumer`, which listens
for all events published by Taipy Core, when a `JOB` entity's `status` attribute is `UPDATE`,
and triggers an external API call based on the `JOB`'s `id`.
for all events published by Taipy Core, when a `JOB^` entity's `status` attribute is `UPDATE`,
and triggers an external API call based on the `JOB^`'s `id`.

jrobinAV marked this conversation as resolved.
Show resolved Hide resolved
!!! example
```python linenums="1"
{%
include-markdown "./code-example/external-api-call-notifier.py"
comments=false
%}
```

```python linenums="1"
{%
include-markdown "./code-example/external-api-call-notifier.py"
comments=false
%}
```
This snippet shows how you can capture and process `JOB` events when an `UPDATE` is made to the `status`
of the `JOB` and request an external API.
For more details, see the [registration](understanding-topics.md) page.

This snippet shows a how you can capture and process `JOB` events when an `UPDATE` is made to the `status`
of the `JOB` and request an external API.
For more details, see the [registration](understanding-notifier-register.md) page.
Loading