@@ -226,9 +226,8 @@ FeatureFlags.addHook(combined)
226226Hooks are executed in the order they were added:
227227
228228``` scala
229- FeatureFlags .addHook(loggingHook) // Runs first in before
230- FeatureFlags .addHook(metricsHook) // Runs second in before
231- FeatureFlags .addHook(validatorHook) // Runs third in before
229+ // Hooks run in registration order (first added = first to run in `before`)
230+ FeatureFlags .addHooks(List (loggingHook, metricsHook, validatorHook))
232231```
233232
234233For the ` before ` stage, hooks run in order. For ` after ` , ` error ` , and ` finallyAfter ` , they run in reverse order.
@@ -261,6 +260,9 @@ Client-level hooks apply to a specific FeatureFlags instance:
261260// Add a single hook at runtime
262261FeatureFlags .addHook(myHook)
263262
263+ // Add multiple hooks atomically
264+ FeatureFlags .addHooks(List (loggingHook, metricsHook, validatorHook))
265+
264266// Create layer with initial hooks
265267val hooks = List (
266268 FeatureHook .logging(),
@@ -444,11 +446,7 @@ override def after[A](...): UIO[Unit] =
444446Consider hook order for dependencies:
445447
446448``` scala
447- // Validation should run first
448- FeatureFlags .addHook(validatorHook)
449- // Then enrichment
450- FeatureFlags .addHook(enrichmentHook)
451- // Then logging/metrics
452- FeatureFlags .addHook(loggingHook)
449+ // Order matters: validation → enrichment → logging
450+ FeatureFlags .addHooks(List (validatorHook, enrichmentHook, loggingHook))
453451```
454452
0 commit comments