From ed820115d86070d3558d9862abc4226f2bfc5af3 Mon Sep 17 00:00:00 2001 From: Beno!t POLASZEK Date: Wed, 29 Nov 2023 11:26:44 +0100 Subject: [PATCH] doc: update React-related documentation --- README.md | 2 +- doc/advanced_usage.md | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 88cc77a..a2a9861 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Table of Contents - [Chaining extractors / transformers / loaders](doc/advanced_usage.md#chaining-extractors--transformers--loaders) - [Reading from STDIN / Writing to STDOUT](doc/advanced_usage.md#reading-from-stdin--writing-to-stdout) - [Instantiators](doc/advanced_usage.md#instantiators) - - [Using React Streams (ReactPHP support)](doc/advanced_usage.md#using-react-streams-experimental) + - [Using ReactPHP](doc/advanced_usage.md#using-reactphp-experimental) - [Recipes](doc/recipes.md) - [Contributing](#contribute) - [License](#license) diff --git a/doc/advanced_usage.md b/doc/advanced_usage.md index 5575d8c..f24b9de 100644 --- a/doc/advanced_usage.md +++ b/doc/advanced_usage.md @@ -159,10 +159,21 @@ $report = withRecipe(new LoggerRecipe($logger)) ->process(['foo', 'bar']); ``` -Using React streams (experimental) +Using ReactPHP (experimental) ---------------------------------- -You can plug your ETL dataflows to any [React Stream](https://github.com/reactphp/stream). +By using the `ReactStreamProcessor` recipe, you can use ReactPHP as the processor of your data. + +> [!IMPORTANT] +> `react/stream` and `react/event-loop` are required for this to work. + +With this processor, you can extract data from an `iterable` or a [React Stream](https://github.com/reactphp/stream): +each item will be iterated within a [Loop tick](https://github.com/reactphp/event-loop#futuretick) instead of a blocking `while` loop. + +This allows you, for example, to: +- [Periodically](https://github.com/reactphp/event-loop#addperiodictimer) perform some stuff (with `Loop::addPeriodicTimer()`) +- Handle [POSIX signals](https://github.com/reactphp/event-loop#addsignal) (with `Loop::addSignal()`) +- Use [React streams](https://github.com/reactphp/stream), like a TCP / HTTP server, a Redis / MySQL connection, or a file stream, for an event-oriented approach. Example with a TCP server: