Skip to content

Commit

Permalink
doc: update React-related documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed Nov 29, 2023
1 parent 8ef8001 commit ed82011
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions doc/advanced_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit ed82011

Please sign in to comment.