@@ -492,10 +492,11 @@ But this means that you must explicitly thread all dependencies from the root of
492
492
through to every child feature. This can be arduous and make it difficult to add, remove or change
493
493
dependencies.
494
494
495
- The library comes with a tool for managing dependencies in a more ergonomic manner, and even comes
496
- with some common dependencies pre-integrated allowing you to access them with no additional work.
497
- For example, the ` date ` dependency ships with the library so that you can declare your feature's
498
- dependence on that functionality in the following way:
495
+ The Composable Architecture now uses the [ Dependencies] [ swift-dependencies ] library to manage
496
+ dependencies in a more ergonomic manner, and even comes with some common dependencies pre-integrated
497
+ allowing you to access them with no additional work. For example, the ` date ` dependency ships with
498
+ the library so that you can declare your feature's dependence on that functionality in the following
499
+ way:
499
500
500
501
``` swift
501
502
struct Feature : ReducerProtocol {
@@ -508,6 +509,17 @@ struct Feature: ReducerProtocol {
508
509
With that one declaration you can stop explicitly passing the date dependency through every layer
509
510
of your application. A date function will be automatically provided to your feature's reducer.
510
511
512
+ > Important: [ Dependencies] [ swift-dependencies ] is powered by Swift task locals and is intended to
513
+ > be used in structured contexts. If your reducer's effects make use of escaping closures, then
514
+ > you must do additional work to propagate the dependencies to that context. For example, using
515
+ > a dependency from within a Combine operator such as ` .map ` , ` .flatMap ` and even ` .filter ` will
516
+ > use the default dependency value.
517
+ >
518
+ > See the [ Dependencies documentation] [ swift-dependencies-docs ] on
519
+ > [ Dependency lifetimes] [ swift-dependencies-docs-lifetimes ] for more information, and how to
520
+ > integrate the ` @Dependency ` property wrapper into pre-structured concurrency using the
521
+ > ` withEscapedDependencies ` function.
522
+
511
523
For domain-specific dependencies you can perform a little bit of upfront work to register your
512
524
dependency with the system, and then it will be automatically available to every layer in your
513
525
application:
@@ -538,6 +550,10 @@ struct Feature: ReducerProtocol {
538
550
For more information on designing your dependencies and providing live and test dependencies, see
539
551
our < doc:Testing > article.
540
552
553
+ [ swift-dependencies ] : https://github.com/pointfreeco/swift-dependencies
554
+ [ swift-dependencies-docs ] : https://pointfreeco.github.io/swift-dependencies/main/documentation/dependencies/
555
+ [ swift-dependencies-docs-lifetimes ] : https://pointfreeco.github.io/swift-dependencies/main/documentation/dependencies/lifetimes
556
+
541
557
## Stores
542
558
543
559
Stores can be initialized from an initial state and an instance of a type conforming to
0 commit comments