Skip to content

Commit

Permalink
Doc: Improve doc about transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek authored Nov 10, 2023
1 parent dce646a commit a9f5c3d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,18 @@ The `EtlState` object contains all elements relative to the state of your ETL wo
Difference between `yield` and `return` in transformers
------------------------------------------------------

A transformer can either return a value, or yield values (like the example above).

The `EtlExecutor::transformWith()` method accepts an unlimited number of transformers as arguments.

When you chain transformers, keep in mind that every transformer will get:
- Either the returned value passed from the previous transformer
- Either an array of every yielded value from the previous transformer
- Either a `Generator` of every yielded value from the previous transformer

But the last transformer of the chain (or your only one transformer) is deterministic to know what will be passed to the loader (either a return value, or a generator):
- If your transformer `returns` a value, this value will be passed to the loader.
- If your transformer `returns` an array of values (or whatever iterable), that return value will be passed to the loader.
- If your transformer `yields` values, each yielded value will be passed to the loader.
But the last transformer of the chain (or your only one transformer) is deterministic to know what will be passed to the loader:
- If your transformer `returns` a value, this value will be passed to the loader (and the loader will be called once for this value).
- If your transformer `returns` an array of values (or whatever iterable), that return value will be passed to the loader (and the loader will be called once for this value).
- If your transformer `yields` values, each yielded value will be passed to the loader (and the loader will be called for each yielded value).

Using events
------------
Expand Down

0 comments on commit a9f5c3d

Please sign in to comment.