Skip to content

Instantly share code, notes, and snippets.

@kalupas226
Last active June 19, 2024 05:11

Revisions

  1. kalupas226 revised this gist Aug 16, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -282,7 +282,7 @@ struct MyApp: App {
    ### Testing

    > **Note**
    > テストに関するより詳細な情報は、[testing](testing-article) 記事を参照してください。
    > テストに関するより詳細な情報は、[testing][testing-article] 記事を参照してください。
    テストするためには `TestStore` を使用します。それは `Store` と同じ情報で作成できますが、actions が送信されたときに機能がどのように変化するかを assert するための追加の作業を行うことになります。

    @@ -390,7 +390,7 @@ await store.send(.factAlertDismissed) {
    また、私たちはアプリケーションの中で `numberFact` の dependency を使用する際の人間工学的な改善も可能です。時間と共にアプリケーションは多くの機能を持つようになり、それらの機能の中には `numberFact` にアクセスしたいものも出てくるかもしれません。全てのレイヤーを通して明示的に `numberFact` を渡すのは煩わしくなってきます。dependency をライブラリに「登録」することで、アプリケーションのどの層でも即座に dependency を利用できるようにするプロセスがあります。

    > **Note**
    > dependency の管理についてのより詳細な情報は、[dependencies](dependencies-article) の記事を参照してください。
    > dependency の管理についてのより詳細な情報は、[dependencies][dependencies-article] の記事を参照してください。
    まず、`numberFact` の機能を新しい型に包むことから始めましょう。

  2. kalupas226 revised this gist Aug 16, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ The Composable Architecture (省略すると TCA) は、コンポジション、

    The Composable Architecture は [Brandon Williams][mbrandonw][Stephen Celis][stephencelis] がホストする、関数型プログラミングと Swift 言語を探求するビデオシリーズである [Point-Free][pointfreeco] の多くのエピソードを経て設計されています。

    全エピソードは[こちら](tca-episode-collection)でご覧いただけます。また、ゼロから Architecture を学ぶ[いくつかのパート](tca-tour)からなる TCA 専用のツアーもあります。
    全エピソードは[こちら][tca-episode-collection]でご覧いただけます。また、ゼロから Architecture を学ぶ[いくつかのパート][tca-tour]からなる TCA 専用のツアーもあります。

    <a href="https://www.pointfree.co/collections/tours/composable-architecture-1-0">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0243.jpeg" width="600">
  3. kalupas226 revised this gist Aug 16, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -537,7 +537,7 @@ Composable Architecture は package の依存関係として追加すること
    * [Spanish](https://gist.github.com/pitt500/f5e32fccb575ce112ffea2827c7bf942)
    * [Ukrainian](https://gist.github.com/barabashd/33b64676195ce41f4bb73c327ea512a8)

    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [PR を作って](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) ください!
    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [PR を作って](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md)ください!

    ## FAQ

  4. kalupas226 revised this gist Aug 15, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -72,7 +72,7 @@ The Composable Architecture は [Brandon Williams][mbrandonw] と [Stephen Celis

    > **Note**
    > ステップ・バイ・ステップのインタラクティブなチュートリアルについては、[Meet the Composable
    > Architecture][meet-tca] をご覧ください.
    > Architecture][meet-tca] を参照してください。
    The Composable Archtiecture を使用して機能を構築するには、ドメインをモデル化するいくつかの型と値を定義します。

  5. kalupas226 revised this gist Aug 15, 2023. No changes.
  6. kalupas226 revised this gist Aug 15, 2023. 1 changed file with 144 additions and 116 deletions.
    260 changes: 144 additions & 116 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    # The Composable Architecture

    [![CI](https://github.com/pointfreeco/swift-composable-architecture/workflows/CI/badge.svg)](https://github.com/pointfreeco/swift-composable-architecture/actions?query=workflow%3ACI)
    [![Slack](https://img.shields.io/badge/slack-chat-informational.svg?label=Slack&logo=slack)](https://www.pointfree.co/slack-invite)
    [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-composable-architecture%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/swift-composable-architecture)
    [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-composable-architecture%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/swift-composable-architecture)

    @@ -11,8 +12,8 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    * [利用例](#利用例)
    * [基本的な利用方法](#基本的な利用方法)
    * [ドキュメント](#ドキュメント)
    * [コミュニティ](#コミュニティ)
    * [インストール方法](#インストール方法)
    * [ヘルプ](#ヘルプ)
    * [翻訳](#翻訳)

    ## The Composable Architecture とは何か?
    @@ -29,26 +30,26 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    <br> 可能な限りテスト可能で理解しやすい方法で、アプリケーションの特定の部分を外界と対話させる方法。

    * **テスト**
    <br > アーキテクチャで構築された機能をテストするだけでなく、多くの Component で構成された機能の Integration test を書いたり、副作用がアプリケーションに与える影響を理解するために E2E テストを書いたりする方法。これにより、ビジネスロジックが期待通りに動作していることを強く保証することができる。
    <br> アーキテクチャで構築された機能をテストするだけでなく、多くの Component で構成された機能の Integration test を書いたり、副作用がアプリケーションに与える影響を理解するために E2E テストを書いたりする方法。これにより、ビジネスロジックが期待通りに動作していることを強く保証することができる。

    * **開発者にとっての使いやすさ**
    <br> 上記の全てを、できるだけ少ないコンセプトと動作するパーツからなるシンプルな API で実現する方法。

    ## もっと学ぶために

    The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw)[Stephen Celis](https://twitter.com/stephencelis) がホストする、関数型プログラミングと Swift 言語を探求するビデオシリーズである [Point-Free](https://www.pointfree.co) の多くのエピソードを経て設計されています。
    The Composable Architecture は [Brandon Williams][mbrandonw][Stephen Celis][stephencelis] がホストする、関数型プログラミングと Swift 言語を探求するビデオシリーズである [Point-Free][pointfreeco] の多くのエピソードを経て設計されています。

    全エピソードは[こちら](https://www.pointfree.co/collections/composable-architecture)でご覧いただけます。また、ゼロから Architecture を学ぶ[いくつかのパート](https://www.pointfree.co/collections/tours/composable-architecture)からなる TCA 専用のツアーもあります。
    全エピソードは[こちら](tca-episode-collection)でご覧いただけます。また、ゼロから Architecture を学ぶ[いくつかのパート](tca-tour)からなる TCA 専用のツアーもあります。

    <a href="https://www.pointfree.co/collections/composable-architecture">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0069.jpeg" width="600">
    <a href="https://www.pointfree.co/collections/tours/composable-architecture-1-0">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0243.jpeg" width="600">
    </a>

    ## 利用例

    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples)

    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す数多くのサンプルが含まれています。この [Examples](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。
    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す _数多くの_ サンプルが含まれています。この [Examples](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。

    * [Case Studies](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/CaseStudies)
    * Getting started
    @@ -60,38 +61,43 @@ The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw
    * [Motion manager](https://github.com/pointfreeco/composable-core-motion/tree/main/Examples/MotionManager)
    * [Search](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/Search)
    * [Speech Recognition](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/SpeechRecognition)
    * [Standups app](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/Standups)
    * [Tic-Tac-Toe](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/TicTacToe)
    * [Todos](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/Todos)
    * [Voice memos](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/VoiceMemos)

    もっと充実したものをお探しですか? SwiftUI と The Composable Architecture で作られた iOS の単語検索ゲームである [isowords](https://github.com/pointfreeco/isowords) のソースコードをチェックしてみてください。
    もっと充実したものをお探しですか? SwiftUI と The Composable Architecture で作られた iOS の単語検索ゲームである [isowords][gh-isowords] のソースコードをチェックしてみてください。

    ## 基本的な利用方法

    > **Note**
    > ステップ・バイ・ステップのインタラクティブなチュートリアルについては、[Meet the Composable
    > Architecture][meet-tca] をご覧ください.
    The Composable Archtiecture を使用して機能を構築するには、ドメインをモデル化するいくつかの型と値を定義します。

    * **State**: あなたのアプリの機能がロジックを実行し、UI をレンダリングするために必要なデータを記述する型です。
    * **Action**: ユーザーのアクション、通知、イベントソースなど、あなたのアプリの機能で起こりうる全てのアクションを表す型です。
    * **Reducer**: Action が与えられた時に、アプリの現在の State を次の State に進化させる方法を記述する関数です。Reducer は API リクエストのような実行すべき Effects を return する役割も担っており、`Effect` を return することでそれを実行できます。
    * **Reducer**: Action が与えられた時に、アプリの現在の State を次の State に進化させる方法を記述する関数です。Reducer は API リクエストのような実行すべき effects を return する役割も担っており、`Effect` を return することでそれを実行できます。
    * **Store**: 実際にあなたのアプリの機能を動かす runtime です。全てのユーザーアクションを Store に送信し、Store は Reducer と Effect を実行できるようにし、Store の状態変化を observe して UI を更新できるようにします。

    この方法の利点は、あなたのアプリの機能のテスタビリティを即座に解除し、大規模で複雑な機能を繋げることができる小さなドメインに分割できるようになることです。

    基本的な例として、数字と数字を増減させる「+」「-」ボタンが表示される UI を考えてみましょう。さらに面白いことに、タップすると API リクエストを行い、その数字に関するランダムな事実を取得し、その事実を Alert で表示するボタンがあるとします
    基本的な例として、数字と数字を増減させる「+」「-」ボタンが表示される UI を考えてみましょう。もっと面白い例にするために、タップすると API リクエストを行い、その数字に関するランダムな事実を取得し、その事実を Alert で表示するボタンがある UI だとします

    この機能を実装するために、ドメインと機能の振る舞いを保持する `ReducerProtocol` に準拠した新しい型を定義することができます。
    この機能を実装するために、ドメインと機能の振る舞いを保持する `Reducer` に準拠した新しい型を定義することができます。

    ```swift
    import ComposableArchitecture

    struct Feature: ReducerProtocol {
    struct Feature: Reducer {
    }
    ```

    ここでは、現在のカウントを表す integer と、表示したいアラートのタイトルを表す String(nil はアラートを表示しないことを表すので optional としている) で構成される機能の state のための型を定義する必要があります。

    ```swift
    struct Feature: ReducerProtocol {
    struct Feature: Reducer {
    struct State: Equatable {
    var count = 0
    var numberFactAlert: String?
    @@ -102,59 +108,52 @@ struct Feature: ReducerProtocol {
    また、機能の actions のための型を定義する必要があります。decrement button, increment button, fact button などをタップするような明らかな actions があります。しかし、ユーザーがアラートを dismiss する action や fact API request から response を受け取るときに発生する action などのような少しわかりにくい actions もあります。

    ```swift
    struct Feature: ReducerProtocol {
    struct State: Equatable { }
    struct Feature: Reducer {
    struct State: Equatable { /* ... */ }
    enum Action: Equatable {
    case factAlertDismissed
    case decrementButtonTapped
    case incrementButtonTapped
    case numberFactButtonTapped
    case numberFactResponse(TaskResult<String>)
    case numberFactResponse(String)
    }
    }
    ```

    そして、機能の実際のロジックや振る舞いをハンドリングする役割を持っている `reduce` メソッドを実装する必要があります。そこには現在の state を次の state に変更する方法を記述し、どのような effects を実行する必要があるのかも記述します。actions によっては effects を実行する必要がないものもあり、その場合は `.none` を return することができます。

    ```swift
    struct Feature: ReducerProtocol {
    struct State: Equatable { }
    enum Action: Equatable { }
    struct Feature: Reducer {
    struct State: Equatable { /* ... */ }
    enum Action: Equatable { /* ... */ }

    func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
    func reduce(into state: inout State, action: Action) -> Effect<Action> {
    switch action {
    case .factAlertDismissed:
    state.numberFactAlert = nil
    return .none

    case .decrementButtonTapped:
    state.count -= 1
    return .none

    case .incrementButtonTapped:
    state.count += 1
    return .none

    case .numberFactButtonTapped:
    return .task { [count = state.count] in
    await .numberFactResponse(
    TaskResult {
    String(
    decoding: try await URLSession.shared
    .data(from: URL(string: "http://numbersapi.com/\(count)/trivia")!).0,
    as: UTF8.self
    )
    }
    )
    }

    case let .numberFactResponse(.success(fact)):
    state.numberFactAlert = fact
    return .none
    case .factAlertDismissed:
    state.numberFactAlert = nil
    return .none

    case .decrementButtonTapped:
    state.count -= 1
    return .none

    case .incrementButtonTapped:
    state.count += 1
    return .none

    case .numberFactButtonTapped:
    return .run { [count = state.count] send in
    let (data, _) = try await URLSession.shared.data(
    from: URL(string: "http://numbersapi.com/\(count)/trivia")!
    )
    await send(
    .numberFactResponse(String(decoding: data, as: UTF8.self))
    )
    }

    case .numberFactResponse(.failure):
    state.numberFactAlert = "Could not load a number fact :("
    return .none
    case let .numberFactResponse(fact):
    state.numberFactAlert = fact
    return .none
    }
    }
    }
    @@ -206,7 +205,7 @@ struct FactAlert: Identifiable {
    var cancellables: Set<AnyCancellable> = []

    init(store: StoreOf<Feature>) {
    self.viewStore = ViewStore(store)
    self.viewStore = ViewStore(store, observe: { $0 })
    super.init(nibName: nil, bundle: nil)
    }

    @@ -269,10 +268,9 @@ struct MyApp: App {
    var body: some Scene {
    WindowGroup {
    FeatureView(
    store: Store(
    initialState: Feature.State(),
    reducer: Feature()
    )
    store: Store(initialState: Feature.State()) {
    Feature()
    }
    )
    }
    }
    @@ -283,17 +281,17 @@ struct MyApp: App {

    ### Testing

    > テストに関するより詳細な情報は、[testing](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/testing) 記事を参照してください。
    > **Note**
    > テストに関するより詳細な情報は、[testing](testing-article) 記事を参照してください。
    テストするためには `TestStore` を使用します。それは `Store` と同じ情報で作成できますが、actions が送信されたときに機能がどのように変化するかを assert するための追加の作業を行うことになります。

    ```swift
    @MainActor
    func testFeature() async {
    let store = TestStore(
    initialState: Feature.State(),
    reducer: Feature()
    )
    let store = TestStore(initialState: Feature.State()) {
    Feature()
    }
    }
    ```

    @@ -326,18 +324,19 @@ await store.receive(.numberFactResponse(.success(???))) {
    この dependency を reducer に渡すことで、デバイス上でアプリケーションを実行するときは実際の dependency を使用し、テストでは mock 化された dependency を使用できるようにするのが良いでしょう。これは `Feature` reducer に property を追加することで実現できます。

    ```swift
    struct Feature: ReducerProtocol {
    struct Feature: Reducer {
    let numberFact: (Int) async throws -> String
    // ...
    }
    ```

    そして、それを `reduce` の実装で使うことができます。

    ```swift
    case .numberFactButtonTapped:
    return .task { [count = state.count] in
    await .numberFactResponse(TaskResult { try await self.numberFact(count) })
    return .run { [count = state.count] send in
    let fact = try await self.numberFact(count)
    await send(.numberFactResponse(fact))
    }
    ```

    @@ -348,16 +347,16 @@ case .numberFactButtonTapped:
    struct MyApp: App {
    var body: some Scene {
    FeatureView(
    store: Store(
    initialState: Feature.State(),
    reducer: Feature(
    store: Store(initialState: Feature.State()) {
    Feature(
    numberFact: { number in
    let (data, _) = try await URLSession.shared
    .data(from: .init(string: "http://numbersapi.com/\(number)")!)
    let (data, _) = try await URLSession.shared.data(
    from: URL(string: "http://numbersapi.com/\(number)")!
    )
    return String(decoding: data, as: UTF8.self)
    }
    )
    )
    }
    )
    }
    }
    @@ -368,12 +367,9 @@ struct MyApp: App {
    ```swift
    @MainActor
    func testFeature() async {
    let store = TestStore(
    initialState: Feature.State(),
    reducer: Feature(
    numberFact: { "\($0) is a good number Brent" }
    )
    )
    let store = TestStore(initialState: Feature.State()) {
    Feature(numberFact: { "\($0) is a good number Brent" })
    }
    }
    ```

    @@ -391,9 +387,10 @@ await store.send(.factAlertDismissed) {
    }
    ```

    また、アプリケーションで `numberFact` の dependency を使用する際の人間工学的な改善も可能です。時間と共にアプリケーションは多くの機能を持つようになり、それらの機能の中には `numberFact` にアクセスしたいものも出てくるかもしれません。全てのレイヤーを通して明示的に `numberFact` を渡すのは煩わしくなってきます。dependency をライブラリに「登録」することで、アプリケーションのどの層でも即座に dependency を利用できるようにするプロセスがあります。
    また、私たちはアプリケーションの中で `numberFact` の dependency を使用する際の人間工学的な改善も可能です。時間と共にアプリケーションは多くの機能を持つようになり、それらの機能の中には `numberFact` にアクセスしたいものも出てくるかもしれません。全てのレイヤーを通して明示的に `numberFact` を渡すのは煩わしくなってきます。dependency をライブラリに「登録」することで、アプリケーションのどの層でも即座に dependency を利用できるようにするプロセスがあります。

    > dependency の管理についてのより詳細な情報は、[dependencies](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/dependencymanagement) の記事を参照してください。
    > **Note**
    > dependency の管理についてのより詳細な情報は、[dependencies](dependencies-article) の記事を参照してください。
    まず、`numberFact` の機能を新しい型に包むことから始めましょう。

    @@ -410,7 +407,8 @@ extension NumberFactClient: DependencyKey {
    static let liveValue = Self(
    fetch: { number in
    let (data, _) = try await URLSession.shared
    .data(from: .init(string: "http://numbersapi.com/\(number)")!)
    .data(from: URL(string: "http://numbersapi.com/\(number)")!
    )
    return String(decoding: data, as: UTF8.self)
    }
    )
    @@ -426,26 +424,30 @@ extension DependencyValues {

    このようなちょっとした作業をすれば、どのような機能でもすぐに dependency を利用し始めることができます。

    ```swift
    struct Feature: ReducerProtocol {
    struct State { }
    enum Action { }
    @Dependency(\.numberFact) var numberFact
    }
    ```diff
    struct Feature: Reducer {
    - let numberFact: (Int) async throws -> String
    + @Dependency(\.numberFact) var numberFact


    - try await self.numberFact(count)
    + try await self.numberFact.fetch(count)
    }
    ```

    このコードは以前と全く同じように動作しますが、機能の reducer を構築する際に dependency を明示的に渡す必要がなくなりました。previews やシミュレータ、デバイス上でアプリを実行する場合は、live dependency が reducer に提供され、テストではテストの dependency が提供されます。

    これは、アプリのエントリポイントが dependency を構築する必要がなくなったことを意味します:

    ```swift
    @main
    struct MyApp: App {
    var body: some Scene {
    FeatureView(
    store: Store(
    initialState: Feature.State(),
    reducer: Feature()
    )
    store: Store(initialState: Feature.State()) {
    Feature()
    }
    )
    }
    }
    @@ -454,49 +456,58 @@ struct MyApp: App {
    また、test store は dependency を指定せずに構築できますが、テストの目的に応じて必要な dependency を override することができます。

    ```swift
    let store = TestStore(
    initialState: Feature.State(),
    reducer: Feature()
    )

    store.dependencies.numberFact.fetch = { "\($0) is a good number Brent" }
    let store = TestStore(initialState: Feature.State()) {
    Feature()
    } withDependencies: {
    $0.numberFact.fetch = { "\($0) is a good number Brent" }
    }

    // ...
    ```

    これが the Composable Architecture で機能を構築しテストするための基本的な方法です。composition (合成)、modularity (モジュール化)、adaptability (適応性)、複雑な effects など、まだまだ探究すべきことが多くあります[Examples](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Examples) ディレクトリには、より高度な使い方を見ることができるプロジェクトが数多くあります。
    これが the Composable Architecture で機能を構築しテストするための基本的な方法です。composition (合成)、modularity (モジュール化)、adaptability (適応性)、複雑な effects など、まだまだ探究すべきことが _多く_ あります[Examples](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Examples) ディレクトリには、より高度な使い方を見ることができるプロジェクトが数多くあります。

    ## ドキュメント

    releases と `main` のドキュメントはこちらで見ることができます。

    * [`main`](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture)
    * [0.46.0](https://pointfreeco.github.io/swift-composable-architecture/0.46.0/documentation/composablearchitecture/)
    * [1.0.0](https://pointfreeco.github.io/swift-composable-architecture/1.0.0/documentation/composablearchitecture/)

    <details>
    <summary>
    Other versions
    他のバージョン
    </summary>

    * [0.45.0](https://pointfreeco.github.io/swift-composable-architecture/0.45.0/documentation/composablearchitecture/)
    * [0.44.0](https://pointfreeco.github.io/swift-composable-architecture/0.44.0/documentation/composablearchitecture/)
    * [0.43.0](https://pointfreeco.github.io/swift-composable-architecture/0.43.0/documentation/composablearchitecture/)
    * [0.42.0](https://pointfreeco.github.io/swift-composable-architecture/0.42.0/documentation/composablearchitecture/)
    * [0.41.2](https://pointfreeco.github.io/swift-composable-architecture/0.41.0/documentation/composablearchitecture/)
    * [0.40.2](https://pointfreeco.github.io/swift-composable-architecture/0.40.0/documentation/composablearchitecture/)
    * [0.39.0](https://pointfreeco.github.io/swift-composable-architecture/0.39.0/documentation/composablearchitecture/)
    * [0.58.0](https://pointfreeco.github.io/swift-composable-architecture/0.58.0/documentation/composablearchitecture/)
    * [0.57.0](https://pointfreeco.github.io/swift-composable-architecture/0.57.0/documentation/composablearchitecture/)
    * [0.56.0](https://pointfreeco.github.io/swift-composable-architecture/0.56.0/documentation/composablearchitecture/)
    * [0.55.0](https://pointfreeco.github.io/swift-composable-architecture/0.55.0/documentation/composablearchitecture/)
    * [0.54.0](https://pointfreeco.github.io/swift-composable-architecture/0.54.0/documentation/composablearchitecture/)
    * [0.53.0](https://pointfreeco.github.io/swift-composable-architecture/0.53.0/documentation/composablearchitecture/)
    * [0.52.0](https://pointfreeco.github.io/swift-composable-architecture/0.52.0/documentation/composablearchitecture/)
    * [0.50.0](https://pointfreeco.github.io/swift-composable-architecture/0.50.0/documentation/composablearchitecture/)
    * [0.49.0](https://pointfreeco.github.io/swift-composable-architecture/0.49.0/documentation/composablearchitecture/)
    </details>

    <br>

    ドキュメントには、ライブラリを使いこなす上で参考になる記事が数多く掲載されています。

    * [Getting started][getting-started-article]
    * [Dependency management][dependencies-article]
    * [Dependencies][dependencies-article]
    * [Testing][testing-article]
    * [Navigation][navigation-article]
    * [Performance][performance-article]
    * [Concurrency][concurrency-article]
    * [Bindings][bindings-article]
    * [Migrating to the reducer protocol][migrating-article]

    ## コミュニティ

    The Composable Architecture について議論したい場合、あるいは特定の問題を解決するために The Composable Architecture をどのように使うかについて質問したい場合、[Point-Free](http://www.pointfree.co) の愛好家仲間と議論できる以下のような多くの場所があります。

    * 長文の議論には、このリポジトリの [discussions][gh-discussions] タブをお勧めします。
    * カジュアルなチャットには、[Point-Free Community slack](http://pointfree.co/slack-invite) をお勧めします。

    ## インストール方法

    @@ -508,25 +519,25 @@ Composable Architecture は package の依存関係として追加すること
    - もしライブラリにアクセスする必要がある単一のアプリケーションターゲットがある場合、アプリケーションに直接 **ComposableArchitecture** を追加してください。
    - もし複数の Xcode ターゲットからこのライブラリを使用したい場合、または Xcode ターゲットと SPM ターゲットを混在させたい場合は **ComposableArchitecture** に依存する共有フレームワークを作成し、全てのターゲットでそのフレームワークに依存する必要があります。この例として、[Tic-Tac-Toe](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/TicTacToe) デモアプリケーションをチェックしてください。これは多くの機能をモジュールに分割し、**tic-tac-toe** Swift package を使用してこの方法で静的ライブラリを使用しています。

    ## ヘルプ

    もし、The Composable Architecture について議論したい、または特定の問題を解決するために TCA をどのように使用するかについて質問がある場合、このリポジトリの [discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) タブでトピックを立ち上げるか、[its Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture) で質問することができます。

    ## 翻訳

    この README の以下の翻訳は、コミュニティのメンバーによって寄稿されたものです。

    * [Arabic](https://gist.github.com/NorhanBoghdadi/1b98d55c02b683ddef7e05c2ebcccd47)
    * [French](https://gist.github.com/nikitamounier/0e93eb832cf389db12f9a69da030a2dc)
    * [Hindi](https://gist.github.com/akashsoni01/b358ee0b3b747167964ef6946123c88d)
    * [Indonesian](https://gist.github.com/wendyliga/792ea9ac5cc887f59de70a9e39cc7343)
    * [Italian](https://gist.github.com/Bellaposa/5114e6d4d55fdb1388e8186886d48958)
    * [Japanese](https://gist.github.com/kalupas226/bdf577e4a7066377ea0a8aaeebcad428)
    * [Korean](https://gist.github.com/pilgwon/ea05e2207ab68bdd1f49dff97b293b17)
    * [Polish](https://gist.github.com/MarcelStarczyk/6b6153051f46912a665c32199f0d1d54)
    * [Portuguese](https://gist.github.com/SevioCorrea/2bbf337cd084a58c89f2f7f370626dc8)
    * [Russian](https://gist.github.com/artyom-ivanov/ed0417fd1f008f0492d3431c033175df)
    * [Simplified Chinese](https://gist.github.com/sh3l6orrr/10c8f7c634a892a9c37214f3211242ad)
    * [Spanish](https://gist.github.com/pitt500/f5e32fccb575ce112ffea2827c7bf942)
    * [Ukrainian](https://gist.github.com/barabashd/33b64676195ce41f4bb73c327ea512a8)

    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [open a PR](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) してください
    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [PR を作って](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) ください

    ## FAQ

    @@ -546,7 +557,7 @@ Composable Architecture は package の依存関係として追加すること

    初期の頃のライブラリにご意見をいただき、現在のライブラリの姿になったのは、以下の方々のおかげです。

    Paul Colton, Kaan Dedeoglu, Matt Diephouse, Josef Doležal, Eimantas, Matthew Johnson, George Kaimakas, Nikita Leonov, Christopher Liscio, Jeffrey Macko, Alejandro Martinez, Shai Mishali, Willis Plummer, Simon-Pierre Roy, Justin Price, Sven A. Schmidt, Kyle Sherman, Petr Šíma, Jasdev Singh, Maxim Smirnov, Ryan Stone, Daniel Hollis Tavares, そして [Point-Free](https://www.pointfree.co) subscribers 全ての人たち 😁.
    Paul Colton, Kaan Dedeoglu, Matt Diephouse, Josef Doležal, Eimantas, Matthew Johnson, George Kaimakas, Nikita Leonov, Christopher Liscio, Jeffrey Macko, Alejandro Martinez, Shai Mishali, Willis Plummer, Simon-Pierre Roy, Justin Price, Sven A. Schmidt, Kyle Sherman, Petr Šíma, Jasdev Singh, Maxim Smirnov, Ryan Stone, Daniel Hollis Tavares, そして [Point-Free][pointfreeco] subscribers 全ての人たち 😁.

    多くの奇妙な SwiftUI の癖を解決し、最終的な API を洗練するのを助けてくれた [Chris Liscio](https://twitter.com/liscio) に特別な感謝を捧げます。

    @@ -575,3 +586,20 @@ The Composable Architecture は、他のライブラリ、特に [Elm](https://e
    ## License

    本ライブラリは、MIT ライセンスで公開されています。詳しくは [LICENSE](https://github.com/pointfreeco/swift-composable-architecture/blob/main/LICENSE) をご覧ください。

    [pointfreeco]: https://www.pointfree.co
    [mbrandonw]: https://twitter.com/mbrandonw
    [stephencelis]: https://twitter.com/stephencelis
    [tca-episode-collection]: https://www.pointfree.co/collections/composable-architecture
    [tca-tour]: https://www.pointfree.co/collections/tours/composable-architecture-1-0
    [gh-isowords]: https://github.com/pointfreeco/isowords
    [gh-discussions]: https://github.com/pointfreeco/swift-composable-architecture/discussions
    [swift-forum]: https://forums.swift.org/c/related-projects/swift-composable-architecture
    [testing-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/testing
    [dependencies-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/dependencymanagement
    [getting-started-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/gettingstarted
    [navigation-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/navigation
    [performance-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/performance
    [concurrency-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/swiftconcurrency
    [bindings-article]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/bindings
    [meet-tca]: https://pointfreeco.github.io/swift-composable-architecture/main/tutorials/meetcomposablearchitecture
  7. kalupas226 revised this gist Dec 4, 2022. 1 changed file with 268 additions and 192 deletions.
    460 changes: 268 additions & 192 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -10,15 +10,10 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    * [もっと学ぶために](#もっと学ぶために)
    * [利用例](#利用例)
    * [基本的な利用方法](#基本的な利用方法)
    * [補助的なライブラリ](#補助的なライブラリ)
    * [FAQ](#faq)
    * [利用するために必要な要件](#利用するために必要な要件)
    * [インストール方法](#インストール方法)
    * [ドキュメント](#ドキュメント)
    * [インストール方法](#インストール方法)
    * [ヘルプ](#ヘルプ)
    * [翻訳](#翻訳)
    * [Credits と thanks](#Credits-と-thanks)
    * [他のライブラリ](#他のライブラリ)

    ## The Composable Architecture とは何か?

    @@ -43,8 +38,7 @@ The Composable Architecture (省略すると TCA) は、コンポジション、

    The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw)[Stephen Celis](https://twitter.com/stephencelis) がホストする、関数型プログラミングと Swift 言語を探求するビデオシリーズである [Point-Free](https://www.pointfree.co) の多くのエピソードを経て設計されています。

    全エピソードは[こちら](https://www.pointfree.co/collections/composable-architecture)でご覧いただけます。また、ゼロから Architecture を学ぶいくつかのパートからなる TCA 専用のツアーもあります。
    [part 1](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep100-a-tour-of-the-composable-architecture-part-1), [part 2](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep101-a-tour-of-the-composable-architecture-part-2), [part 3](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep102-a-tour-of-the-composable-architecture-part-3), [part 4](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep103-a-tour-of-the-composable-architecture-part-4).
    全エピソードは[こちら](https://www.pointfree.co/collections/composable-architecture)でご覧いただけます。また、ゼロから Architecture を学ぶ[いくつかのパート](https://www.pointfree.co/collections/tours/composable-architecture)からなる TCA 専用のツアーもあります。

    <a href="https://www.pointfree.co/collections/composable-architecture">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0069.jpeg" width="600">
    @@ -54,7 +48,7 @@ The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw

    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples)

    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す数多くのサンプルが含まれています。この [Exampleshttps://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。
    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す数多くのサンプルが含まれています。この [Examples](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。

    * [Case Studies](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/CaseStudies)
    * Getting started
    @@ -78,86 +72,103 @@ The Composable Archtiecture を使用して機能を構築するには、ドメ

    * **State**: あなたのアプリの機能がロジックを実行し、UI をレンダリングするために必要なデータを記述する型です。
    * **Action**: ユーザーのアクション、通知、イベントソースなど、あなたのアプリの機能で起こりうる全てのアクションを表す型です。
    * **Environment**: API クライアントや Analytics クライアントなど、あなたのアプリの機能が必要とするあらゆる依存関係を保持する型です。
    * **Reducer**: Action が与えられた時に、アプリの現在の State を次の State に進化させる方法を記述する関数です。Reducer は API リクエストのような実行すべき Effects を return する役割も担っており、`Effect` を return することでそれを実行できます。
    * **Store**: 実際にあなたのアプリの機能を動かす runtime です。全てのユーザーアクションを Store に送信し、Store は Reducer と Effect を実行できるようにし、Store の状態変化を observe して UI を更新できるようにします。

    この方法の利点は、あなたのアプリの機能のテスタビリティを即座に解除し、大規模で複雑な機能を繋げることができる小さなドメインに分割できるようになることです。

    基本的な例として、数字と数字を増減させる「+」「-」ボタンが表示される UI を考えてみましょう。さらに面白いことに、タップすると API リクエストを行い、その数字に関するランダムな事実を取得し、その事実を Alert で表示するボタンがあるとします。

    この機能の State は、現在のカウントを表す integer と表示したい Alert のタイトルを表す optional な string で構成されます。 (`nil` は Alert を表示しないということを表すため、Alert のタイトルは optional として表現されます)
    この機能を実装するために、ドメインと機能の振る舞いを保持する `ReducerProtocol` に準拠した新しい型を定義することができます。

    ```swift
    struct AppState: Equatable {
    var count = 0
    var numberFactAlert: String?
    import ComposableArchitecture

    struct Feature: ReducerProtocol {
    }
    ```

    次に、その機能における Action です。数字を減少させるボタン、増加させるボタン、または数字についての事実を表示するためのボタンをタップするような、明白な Action があります。しかし、ユーザーが Alert を解除する Action や、数字についての事実を取得するための API リクエストからレスポンスを受信した時に発生する Action など、少しわかりにくい Action もあります
    ここでは、現在のカウントを表す integer と、表示したいアラートのタイトルを表す String(nil はアラートを表示しないことを表すので optional としている) で構成される機能の state のための型を定義する必要があります

    ```swift
    enum AppAction: Equatable {
    case factAlertDismissed
    case decrementButtonTapped
    case incrementButtonTapped
    case numberFactButtonTapped
    case numberFactResponse(TaskResult<String>)
    struct Feature: ReducerProtocol {
    struct State: Equatable {
    var count = 0
    var numberFactAlert: String?
    }
    }

    struct ApiError: Error, Equatable {}
    ```

    次に、この機能が動作するために必要な依存関係の Environment をモデル化します。特に、`numberFact` を取得するために `Int` から `String` への async throwing function をモデル化することができます
    また、機能の actions のための型を定義する必要があります。decrement button, increment button, fact button などをタップするような明らかな actions があります。しかし、ユーザーがアラートを dismiss する action や fact API request から response を受け取るときに発生する action などのような少しわかりにくい actions もあります

    ```swift
    struct AppEnvironment {
    var numberFact: (Int) async throws -> String
    struct Feature: ReducerProtocol {
    struct State: Equatable { }
    enum Action: Equatable {
    case factAlertDismissed
    case decrementButtonTapped
    case incrementButtonTapped
    case numberFactButtonTapped
    case numberFactResponse(TaskResult<String>)
    }
    }
    ```

    次に、このアプリのドメインロジックを実装した Reducer を実装します。現在の State を次の State に変更する方法を記述し、どのような Effect を実行する必要があるかを記述しています。Action によっては、Effect を実行する必要がないものもあるので、それを表すために `.none` を return することができます。
    そして、機能の実際のロジックや振る舞いをハンドリングする役割を持っている `reduce` メソッドを実装する必要があります。そこには現在の state を次の state に変更する方法を記述し、どのような effects を実行する必要があるのかも記述します。actions によっては effects を実行する必要がないものもあり、その場合は `.none` を return することができます。

    ```swift
    let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, environment in
    switch action {
    case .factAlertDismissed:
    state.numberFactAlert = nil
    return .none

    case .decrementButtonTapped:
    state.count -= 1
    return .none

    case .incrementButtonTapped:
    state.count += 1
    return .none

    case .numberFactButtonTapped:
    return .task {
    await .numberFactResponse(TaskResult { try await environment.numberFact(state.count) })
    }
    struct Feature: ReducerProtocol {
    struct State: Equatable { }
    enum Action: Equatable { }

    func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
    switch action {
    case .factAlertDismissed:
    state.numberFactAlert = nil
    return .none

    case .decrementButtonTapped:
    state.count -= 1
    return .none

    case .incrementButtonTapped:
    state.count += 1
    return .none

    case .numberFactButtonTapped:
    return .task { [count = state.count] in
    await .numberFactResponse(
    TaskResult {
    String(
    decoding: try await URLSession.shared
    .data(from: URL(string: "http://numbersapi.com/\(count)/trivia")!).0,
    as: UTF8.self
    )
    }
    )
    }

    case let .numberFactResponse(.success(fact)):
    state.numberFactAlert = fact
    return .none
    case let .numberFactResponse(.success(fact)):
    state.numberFactAlert = fact
    return .none

    case .numberFactResponse(.failure):
    state.numberFactAlert = "Could not load a number fact :("
    return .none
    case .numberFactResponse(.failure):
    state.numberFactAlert = "Could not load a number fact :("
    return .none
    }
    }
    }
    ```

    そして最後に、アプリの機能を表示する View を定義します。View では `Store<AppState, AppAction>` を保持し、State への全ての変更を observe して再レンダリングするできるようにします。また、State が変化するように、全てのユーザーの Action を Store に送ることができます。また `.alert` view modifier が必要とする `Identifiable` を実現するために、数に関する事実を表示する Alert の周りに struct のラッパーを導入する必要があります。
    そして最後に、機能を表示する View を定義します。その View では `StoreOf<Feature>` を保持して、state への全ての変更を observe して再レンダリングできるようにし、state を変化させるためにユーザーの actions を store に送信できるようにします。また、
    `.alert` view modifier が必要とする `Identifiable` を満たせるように、fact アラートの周辺に struct の wrapper を導入する必要があります。

    ```swift
    struct AppView: View {
    let store: Store<AppState, AppAction>
    struct FeatureView: View {
    let store: StoreOf<Feature>

    var body: some View {
    WithViewStore(self.store) { viewStore in
    WithViewStore(self.store, observe: { $0 }) { viewStore in
    VStack {
    HStack {
    Button("") { viewStore.send(.decrementButtonTapped) }
    @@ -184,19 +195,17 @@ struct FactAlert: Identifiable {
    }
    ```

    重要なのは、この機能全体を実際に手元で Live Effect (実際のリクエスト) なしで実装できたということです。これは、依存関係を構築することなく機能を分離して構築できることを意味し、コンパイル時間の短縮に繋げることができるため重要です。

    また、この Store から UIKit の Controller を駆動させることも簡単です。UI を更新して Alert を表示するために、`viewDidLoad` で Store を subscribe すれば良いのです。コードは SwiftUI バージョンよりも少し長いため、折りたたんでいます。
    また、この store から UIKit controller を駆動させることも簡単です。UI を更新して alert を表示するために `viewDidLoad` で store を subscribe すれば良いだけです。コードは SwiftUI 版より少し長いので、以下に折りたたみます。

    <details>
    <summary>クリックして展開してください!</summary>
    <summary>展開するためにクリックしてください!</summary>

    ```swift
    class AppViewController: UIViewController {
    let viewStore: ViewStore<AppState, AppAction>
    class FeatureViewController: UIViewController {
    let viewStore: ViewStoreOf<Feature>
    var cancellables: Set<AnyCancellable> = []

    init(store: Store<AppState, AppAction>) {
    init(store: StoreOf<Feature>) {
    self.viewStore = ViewStore(store)
    super.init(nibName: nil, bundle: nil)
    }
    @@ -250,204 +259,255 @@ struct FactAlert: Identifiable {
    ```
    </details>

    この View を表示する準備ができたら、例えばアプリのエントリーポイントで Store を構築することができます。この時、fact を取得するために実際に実世界の API にアクセスする `numberFact` endpoint などの依存関係を提供する必要があります
    この view を表示する準備ができたら、例えばアプリのエントリポイントで store を構築することができます。これは、アプリケーションを起動するための初期 state や、アプリケーションを動かす reducer を指定することで実現できます

    ```swift
    import ComposableArchitecture

    @main
    struct CaseStudiesApp: App {
    struct MyApp: App {
    var body: some Scene {
    AppView(
    store: Store(
    initialState: AppState(),
    reducer: apReducer,
    environment: AppEnvironment(
    numberFact: { number in
    let (data, _) = try await URLSession.shared
    .data(from: .init(string: "http://numbersapi.com/\(number)")!)
    return String(decoding: data, using: UTF8.self)
    }
    WindowGroup {
    FeatureView(
    store: Store(
    initialState: Feature.State(),
    reducer: Feature()
    )
    )
    )
    }
    }
    }
    ```

    そしてそれは、Screen 上で実装していく方法を得るために十分です。素の SwiftUI の方法でこれを行う場合よりも、確かにいくつかのステップを必要としますが、いくつかの利点があります。いくつかの Observable な Object や UI Component のさまざまな Action closure でロジックを散乱させる代わりに、State の変更を適用するための一貫した方法を提供します。また、副作用を簡潔に表現することができます。そして、このロジックは Effect を含め、すぐにテストすることができます。
    そしてそれはスクリーン上で遊ぶための何かを得るのに十分です。vanilla SwiftUI (素の SwiftUI) で同様の挙動を実現する場合よりも、確かにいくつかのステップを必要としますが、いくつかの利点があります。いくつかの observable objects や UI components の様々な action closures でロジックをばら撒く代わりに、state の mutation を適用するための一貫した方法を提供してくれます。また、副作用を簡潔に表現することもできます。そして、これらのロジックは effects を含めてすぐにテストすることができます。

    ### Testing

    ### テスト
    > テストに関するより詳細な情報は、[testing](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/testing) 記事を参照してください。
    テストを行うには、まず通常の `Store` を作成するのと同じ情報を使って `TestStore` を作成します。ただし、今回はテストに適した依存関係を提供することができます。特に、`numberFact` の実装では、実世界にアクセスするのではなく、私たちがコントロールできる値を即座に返すことができるようになりました
    テストするためには `TestStore` を使用します。それは `Store` と同じ情報で作成できますが、actions が送信されたときに機能がどのように変化するかを assert するための追加の作業を行うことになります

    ```swift
    @MainActor
    func testFeature() async {
    let store = TestStore(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(
    numberFact: { "\($0) is a good number Brent" }
    )
    initialState: Feature.State(),
    reducer: Feature()
    )
    }
    ```

    Test store を作成したら、それを使ってユーザーフロー全体のステップを assertion することができます。各ステップごとに、State が期待通りに変化したことを証明する必要があります。さらに、あるステップで Effect が実行され、それが Store にデータをフィードバックする場合、それらの Action が適切に受信されたことを保証する必要があります。

    以下のテストでは、ユーザーがカウントをインクリメント・デクリメントし、その後数字についての事実を尋ね、その Effect のレスポンスが Alert を表示するトリガーとなり、その後 Alert を解除すると Alert が消えることを確かめています。
    test store を作成したら、それを使ってユーザーフロー全体のステップを assertion することができます。各ステップごとに、state が期待通りに変化したことを証明する必要があります。例えば、increment button と decrement button をタップするというユーザーフローをシミュレートすることができます。

    ```swift
    // インクリメント/デクリメントボタンをタップするとカウントが変化することを確認する
    // increment/decrement button をタップするとカウントが変化することをテストする
    await store.send(.incrementButtonTapped) {
    $0.count = 1
    }
    await store.send(.decrementButtonTapped) {
    $0.count = 0
    }
    ```

    さらに、ステップによって effect が実行され、データが store にフィードバックされる場合、それについて assert しなければなりません。例えば、ユーザーが fact button をタップすることをシミュレートする場合、fact を含む response が返却され、それによって alert が表示されることを期待します。

    // fact ボタンをタップすると、Effect からレスポンスが返ってくることをテストします。注意
    // Effect は非同期であるため receive を await する必要があります。
    // 実際に値が放出されるのに少量の時間がかかるからです。
    ```swift
    await store.send(.numberFactButtonTapped)

    await store.receive(.numberFactResponse(.success("0 is a good number Brent"))) {
    $0.numberFactAlert = "0 is a good number Brent"
    await store.receive(.numberFactResponse(.success(???))) {
    $0.numberFactAlert = ???
    }
    ```

    // And finally dismiss the alert
    await store.send(.factAlertDismissed) {
    $0.numberFactAlert = nil
    しかし、どのような fact が送り返されるかをどうやって知ることができるでしょうか?

    現在、私たちの reducer は API server を叩くために実世界に到達する effect を使用しており、それは私たちがその動作を制御する方法がないことを意味しています。このテストを書くために、私たちはインターネット接続と API server の可用性の気まぐれにさらされています。

    この dependency を reducer に渡すことで、デバイス上でアプリケーションを実行するときは実際の dependency を使用し、テストでは mock 化された dependency を使用できるようにするのが良いでしょう。これは `Feature` reducer に property を追加することで実現できます。

    ```swift
    struct Feature: ReducerProtocol {
    let numberFact: (Int) async throws -> String
    }
    ```

    これが The Composable Architecture の機能を構築し、テストするための基本です。コンポジション、モジュール化、適応性、複雑な Effect など、探究すべきことはもっとたくさんあります。[Examples](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリには、より高度な使い方を見るためのプロジェクトがたくさんあります
    そして、それを `reduce` の実装で使うことができます

    ### デバッグ
    ```swift
    case .numberFactButtonTapped:
    return .task { [count = state.count] in
    await .numberFactResponse(TaskResult { try await self.numberFact(count) })
    }
    ```

    The Composable Architecture には、デバッグを支援するためのツールが多数付属しています
    そして、アプリケーションのエントリポイントでは、実際に現実の API server と対話する dependency を提供することができます

    * `reducer.debug()` は、Reducer が受け取る全ての Action と State に対する全ての変更を記述する debug-printing で、Reducer を強化します。
    ```swift
    @main
    struct MyApp: App {
    var body: some Scene {
    FeatureView(
    store: Store(
    initialState: Feature.State(),
    reducer: Feature(
    numberFact: { number in
    let (data, _) = try await URLSession.shared
    .data(from: .init(string: "http://numbersapi.com/\(number)")!)
    return String(decoding: data, as: UTF8.self)
    }
    )
    )
    )
    }
    }
    ```

    ``` diff
    received action:
    AppAction.todoCheckboxTapped(id: UUID(5834811A-83B4-4E5E-BCD3-8A38F6BDCA90))
      AppState(
      todos: [
      Todo(
    - isComplete: false,
    + isComplete: true,
      description: "Milk",
      id: 5834811A-83B4-4E5E-BCD3-8A38F6BDCA90
      ),
      … (2 unchanged)
      ]
      )
    ```
    しかし、テストでは決定論的で予測可能な fact を即座に返す mock dependency を使用することができます。

    * `reducer.signpost()` は Reducer に signpost をつけて、Action の実行にかかる時間や Effect が実行されるタイミングを知ることができるようにします。
    ```swift
    @MainActor
    func testFeature() async {
    let store = TestStore(
    initialState: Feature.State(),
    reducer: Feature(
    numberFact: { "\($0) is a good number Brent" }
    )
    )
    }
    ```

    <img src="https://s3.amazonaws.com/pointfreeco-production/point-free-pointers/0044-signposts-cover.jpg" width="600">
    このように少しの作業で、ユーザーが fact button をタップし、dependency から response を受け取り、アラートをトリガーし、アラートを dismiss することをシミュレートして、テストを終了することができます。

    ## 補助的なライブラリ
    ```swift
    await store.send(.numberFactButtonTapped)

    The Composable Architecture の最も重要な原則の一つは、副作用は決して直接実行されず、代わりに `Effect` 型にラップされて Reducer から return され、後で `Store` が Effect を実行することです。これはアプリケーション内のデータの流れを単純化し、ユーザーアクションから Effect の実行までの完全な E2E テスト容易性を得るために重要なことです。
    await store.receive(.numberFactResponse(.success("0 is a good number Brent"))) {
    $0.numberFactAlert = "0 is a good number Brent"
    }

    しかし、これはあなたが日常的に使っている多くのライブラリや SDK が The Composable Architecture のスタイルにもう少しフレンドリーであるように改修する必要があることも意味しています。そういうわけで、私たちは Apple の最も人気のあるフレームワークのいくつかを、私たちのライブラリとうまく連携する方法でその機能を公開するラッパーライブラリを提供することで、The Composable Architecture 使用時の苦痛を軽減したいと思っています。今のところ、私たちは以下をサポートしています。
    await store.send(.factAlertDismissed) {
    $0.numberFactAlert = nil
    }
    ```

    * [`ComposableCoreLocation`](https://github.com/pointfreeco/composable-core-location): `CLLocationManager` のラッパーです。Reducer から簡単に利用することができ、あなたのアプリのロジックが `CLLocationManager` の機能とどのように相互作用するかのテストを簡単に書くことができます。
    * [`ComposableCoreMotion`](https://github.com/pointfreeco/composable-core-motion): `CMMotionManager` のラッパーです。Reducer から簡単に利用することができ、あなたのアプリのロジックが `CMMotionManager` の機能とどのように相互作用するかのテストを簡単に書くことができます。
    * より多くのラッパーは近日公開予定です。ご期待ください 😉
    また、アプリケーションで `numberFact` の dependency を使用する際の人間工学的な改善も可能です。時間と共にアプリケーションは多くの機能を持つようになり、それらの機能の中には `numberFact` にアクセスしたいものも出てくるかもしれません。全てのレイヤーを通して明示的に `numberFact` を渡すのは煩わしくなってきます。dependency をライブラリに「登録」することで、アプリケーションのどの層でも即座に dependency を利用できるようにするプロセスがあります。

    もし、私たちがまだカバーしていないフレームワークのラッパーライブラリを提供することに興味があれば、遠慮なくあなたの関心を表現する issue をオープンしてください
    > dependency の管理についてのより詳細な情報は、[dependencies](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/dependencymanagement) の記事を参照してください
    ## FAQ
    まず、`numberFact` の機能を新しい型に包むことから始めましょう。

    * The Composable Architecture は Elm や Redux などと比較してどうなのでしょうか?
    <details>
    <summary>答えを見るために展開する</summary>
    The Composable Architecture (TCA) は、Elm Architecture (TEA) と Redux で広まったアイデアを基礎に、Swift 言語と Apple のプラットフォームで快適に動作するように作られています。
    ```swift
    struct NumberFactClient {
    var fetch: (Int) async throws -> String
    }
    ```

    ある意味、TCA は他のライブラリよりも少し意見が強いと言えます。例えば、Redux は副作用の実行方法について規定がありませんが、TCA は全ての副作用を `Effect` 型でモデル化し、Reducer から返すことを要求しています
    そして、client を `DependencyKey` protocol に準拠させることで、その型を dependency の管理システムに登録します。この protocol では、シミュレータやデバイスでアプリケーションを実行するときに使用する live value (実際の値) を指定することが求められます

    他の点では、TCA は他のライブラリよりも少し緩いと言えます。例えば Elm は `Cmd` 型を介してどのような種類の Effect を作成できるかを制御しますが、TCA では `Effect` が Combine `Publisher` protocol に準拠しているため、どのような種類の Effect にもすることが可能です。
    ```swift
    extension NumberFactClient: DependencyKey {
    static let liveValue = Self(
    fetch: { number in
    let (data, _) = try await URLSession.shared
    .data(from: .init(string: "http://numbersapi.com/\(number)")!)
    return String(decoding: data, as: UTF8.self)
    }
    )
    }

    そして、Redux や Elm、あるいは他のほとんどのライブラリでは重視されない、TCA が非常に優先していることがあるのです。例えば、コンポジションは TCA にとって非常に重要な側面であり、大きな機能をより小さな Unit に分解し、それを繋げるプロセスです。これは Reducer の `pullback` と `combine` operator で実現され、複雑な機能の処理と、より分離されたコードベースとコンパイル時間の改善のためのモジュール化を支援します。
    </details>
    extension DependencyValues {
    var numberFact: NumberFactClient {
    get { self[NumberFactClient.self] }
    set { self[NumberFactClient.self] = newValue }
    }
    }
    ```

    ## 利用するために必要な要件
    このようなちょっとした作業をすれば、どのような機能でもすぐに dependency を利用し始めることができます。

    The Composable Architecture は Combine フレームワークに依存しているため、最低でも iOS 13, macOS 10.15, Mac Catalyst 13, tvOS 13, watchOS 6 のデプロイメントターゲットが必要です。どうしても古い OS に対応したい場合は、[ReactiveSwift](https://github.com/trading-point/reactiveswift-composable-architecture) や [RxSwift](https://github.com/dannyhertz/rxswift-composable-architecture) の fork がありますので、そちらを採用してください!
    ```swift
    struct Feature: ReducerProtocol {
    struct State { }
    enum Action { }
    @Dependency(\.numberFact) var numberFact
    }
    ```

    ## インストール方法
    このコードは以前と全く同じように動作しますが、機能の reducer を構築する際に dependency を明示的に渡す必要がなくなりました。previews やシミュレータ、デバイス上でアプリを実行する場合は、live dependency が reducer に提供され、テストではテストの dependency が提供されます。

    The Composable Architecture は package の依存関係として追加することで、Xcode プロジェクトに追加することができます。
    ```swift
    @main
    struct MyApp: App {
    var body: some Scene {
    FeatureView(
    store: Store(
    initialState: Feature.State(),
    reducer: Feature()
    )
    )
    }
    }
    ```

    1. **File** メニューから、**Add Packages...** を選択します。
    2. package リポジトリの URL のテキストフィールドに "https://github.com/pointfreeco/swift-composable-architecture" を入力します。
    3. プロジェクトの構成によって異なります。
    - もしライブラリにアクセスする必要がある単一のアプリケーションターゲットがある場合、アプリケーションに直接 **ComposableArchitecture** を追加してください。
    - もし複数の Xcode ターゲットからこのライブラリを使用したい場合、または Xcode ターゲットと SPM ターゲットを混在させたい場合は **ComposableArchitecture** に依存する共有フレームワークを作成し、全てのターゲットでそのフレームワークに依存する必要があります。この例として、[Tic-Tac-Toe](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/TicTacToe) デモアプリケーションをチェックしてください。これは多くの機能をモジュールに分割し、**tic-tac-toe** Swift package を使用してこの方法で静的ライブラリを使用しています。
    また、test store は dependency を指定せずに構築できますが、テストの目的に応じて必要な dependency を override することができます。

    ```swift
    let store = TestStore(
    initialState: Feature.State(),
    reducer: Feature()
    )

    store.dependencies.numberFact.fetch = { "\($0) is a good number Brent" }

    ```

    これが the Composable Architecture で機能を構築しテストするための基本的な方法です。composition (合成)、modularity (モジュール化)、adaptability (適応性)、複雑な effects など、まだまだ探究すべきことが多くあります。[Examples](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Examples) ディレクトリには、より高度な使い方を見ることができるプロジェクトが数多くあります。

    ## ドキュメント

    releases と `main` のドキュメントはこちらでご覧になれます
    releases と `main` のドキュメントはこちらで見ることができます

    * [`main`](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture)
    * [0.39.0](https://pointfreeco.github.io/swift-composable-architecture/0.39.0/documentation/composablearchitecture/)
    * [0.46.0](https://pointfreeco.github.io/swift-composable-architecture/0.46.0/documentation/composablearchitecture/)
    <details>
    <summary>
    他のバージョン
    Other versions
    </summary>

    * [0.38.0](https://pointfreeco.github.io/swift-composable-architecture/0.38.0/documentation/composablearchitecture/)
    * [0.37.0](https://pointfreeco.github.io/swift-composable-architecture/0.37.0/documentation/composablearchitecture)
    * [0.36.0](https://pointfreeco.github.io/swift-composable-architecture/0.36.0/documentation/composablearchitecture)
    * [0.35.0](https://pointfreeco.github.io/swift-composable-architecture/0.35.0/documentation/composablearchitecture)
    * [0.34.0](https://pointfreeco.github.io/swift-composable-architecture/0.34.0/documentation/composablearchitecture)
    * [0.33.1](https://pointfreeco.github.io/swift-composable-architecture/0.33.1/documentation/composablearchitecture)
    * [0.33.0](https://pointfreeco.github.io/swift-composable-architecture/0.33.0/documentation/composablearchitecture)
    * [0.32.0](https://pointfreeco.github.io/swift-composable-architecture/0.32.0/documentation/composablearchitecture)
    * [0.31.0](https://pointfreeco.github.io/swift-composable-architecture/0.31.0/documentation/composablearchitecture)
    * [0.30.0](https://pointfreeco.github.io/swift-composable-architecture/0.30.0/documentation/composablearchitecture)
    * [0.29.0](https://pointfreeco.github.io/swift-composable-architecture/0.29.0/documentation/composablearchitecture)
    * [0.28.1](https://pointfreeco.github.io/swift-composable-architecture/0.28.1/documentation/composablearchitecture)
    * [0.28.0](https://pointfreeco.github.io/swift-composable-architecture/0.28.0/documentation/composablearchitecture)
    * [0.27.1](https://pointfreeco.github.io/swift-composable-architecture/0.27.1/documentation/composablearchitecture)
    * [0.27.0](https://pointfreeco.github.io/swift-composable-architecture/0.27.0/documentation/composablearchitecture)
    * [0.26.0](https://pointfreeco.github.io/swift-composable-architecture/0.26.0/documentation/composablearchitecture)
    * [0.25.1](https://pointfreeco.github.io/swift-composable-architecture/0.25.1/documentation/composablearchitecture)
    * [0.25.0](https://pointfreeco.github.io/swift-composable-architecture/0.25.0/documentation/composablearchitecture)
    * [0.24.0](https://pointfreeco.github.io/swift-composable-architecture/0.24.0/documentation/composablearchitecture)
    * [0.23.0](https://pointfreeco.github.io/swift-composable-architecture/0.23.0/documentation/composablearchitecture)
    * [0.22.0](https://pointfreeco.github.io/swift-composable-architecture/0.22.0/documentation/composablearchitecture)
    * [0.21.0](https://pointfreeco.github.io/swift-composable-architecture/0.21.0/documentation/composablearchitecture)
    * [0.20.0](https://pointfreeco.github.io/swift-composable-architecture/0.20.0/documentation/composablearchitecture)
    * [0.19.0](https://pointfreeco.github.io/swift-composable-architecture/0.19.0/documentation/composablearchitecture)
    * [0.18.0](https://pointfreeco.github.io/swift-composable-architecture/0.18.0/documentation/composablearchitecture)
    * [0.17.0](https://pointfreeco.github.io/swift-composable-architecture/0.17.0/documentation/composablearchitecture)
    * [0.16.0](https://pointfreeco.github.io/swift-composable-architecture/0.16.0/documentation/composablearchitecture)
    * [0.15.0](https://pointfreeco.github.io/swift-composable-architecture/0.15.0/documentation/composablearchitecture)
    * [0.14.0](https://pointfreeco.github.io/swift-composable-architecture/0.14.0/documentation/composablearchitecture)
    * [0.13.0](https://pointfreeco.github.io/swift-composable-architecture/0.13.0/documentation/composablearchitecture)
    * [0.12.0](https://pointfreeco.github.io/swift-composable-architecture/0.12.0/documentation/composablearchitecture)
    * [0.11.0](https://pointfreeco.github.io/swift-composable-architecture/0.11.0/documentation/composablearchitecture)
    * [0.10.0](https://pointfreeco.github.io/swift-composable-architecture/0.10.0/documentation/composablearchitecture)
    * [0.9.0](https://pointfreeco.github.io/swift-composable-architecture/0.9.0/documentation/composablearchitecture)
    * [0.8.0](https://pointfreeco.github.io/swift-composable-architecture/0.8.0/documentation/composablearchitecture)
    * [0.7.0](https://pointfreeco.github.io/swift-composable-architecture/0.7.0/documentation/composablearchitecture)
    * [0.6.0](https://pointfreeco.github.io/swift-composable-architecture/0.6.0/documentation/composablearchitecture)
    * [0.5.0](https://pointfreeco.github.io/swift-composable-architecture/0.5.0/documentation/composablearchitecture)
    * [0.4.0](https://pointfreeco.github.io/swift-composable-architecture/0.4.0/documentation/composablearchitecture)
    * [0.3.0](https://pointfreeco.github.io/swift-composable-architecture/0.3.0/documentation/composablearchitecture)
    * [0.2.0](https://pointfreeco.github.io/swift-composable-architecture/0.2.0/documentation/composablearchitecture)
    * [0.1.5](https://pointfreeco.github.io/swift-composable-architecture/0.1.5/documentation/composablearchitecture)
    * [0.1.4](https://pointfreeco.github.io/swift-composable-architecture/0.1.4/documentation/composablearchitecture)
    * [0.1.3](https://pointfreeco.github.io/swift-composable-architecture/0.1.3/documentation/composablearchitecture)
    * [0.1.2](https://pointfreeco.github.io/swift-composable-architecture/0.1.2/documentation/composablearchitecture)
    * [0.1.1](https://pointfreeco.github.io/swift-composable-architecture/0.1.1/documentation/composablearchitecture)
    * [0.1.0](https://pointfreeco.github.io/swift-composable-architecture/0.1.0/documentation/composablearchitecture)
    * [0.45.0](https://pointfreeco.github.io/swift-composable-architecture/0.45.0/documentation/composablearchitecture/)
    * [0.44.0](https://pointfreeco.github.io/swift-composable-architecture/0.44.0/documentation/composablearchitecture/)
    * [0.43.0](https://pointfreeco.github.io/swift-composable-architecture/0.43.0/documentation/composablearchitecture/)
    * [0.42.0](https://pointfreeco.github.io/swift-composable-architecture/0.42.0/documentation/composablearchitecture/)
    * [0.41.2](https://pointfreeco.github.io/swift-composable-architecture/0.41.0/documentation/composablearchitecture/)
    * [0.40.2](https://pointfreeco.github.io/swift-composable-architecture/0.40.0/documentation/composablearchitecture/)
    * [0.39.0](https://pointfreeco.github.io/swift-composable-architecture/0.39.0/documentation/composablearchitecture/)
    </details>

    <br>

    ドキュメントには、ライブラリを使いこなす上で参考になる記事が数多く掲載されています。

    * [Getting started][getting-started-article]
    * [Dependency management][dependencies-article]
    * [Testing][testing-article]
    * [Performance][performance-article]
    * [Concurrency][concurrency-article]
    * [Bindings][bindings-article]
    * [Migrating to the reducer protocol][migrating-article]

    ## インストール方法

    Composable Architecture は package の依存関係として追加することで、Xcode プロジェクトに追加することができます。

    1. **File** メニューから、**Add Packages...** を選択します。
    2. package リポジトリの URL のテキストフィールドに "https://github.com/pointfreeco/swift-composable-architecture" を入力します。
    3. プロジェクトの構成によって異なります。
    - もしライブラリにアクセスする必要がある単一のアプリケーションターゲットがある場合、アプリケーションに直接 **ComposableArchitecture** を追加してください。
    - もし複数の Xcode ターゲットからこのライブラリを使用したい場合、または Xcode ターゲットと SPM ターゲットを混在させたい場合は **ComposableArchitecture** に依存する共有フレームワークを作成し、全てのターゲットでそのフレームワークに依存する必要があります。この例として、[Tic-Tac-Toe](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/TicTacToe) デモアプリケーションをチェックしてください。これは多くの機能をモジュールに分割し、**tic-tac-toe** Swift package を使用してこの方法で静的ライブラリを使用しています。

    ## ヘルプ

    もし、The Composable Architecture について議論したい、または特定の問題を解決するために TCA をどのように使用するかについて質問がある場合、このリポジトリの [discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) タブでトピックを立ち上げるか、[its Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture) で質問することができます。
    @@ -460,12 +520,28 @@ releases と `main` のドキュメントはこちらでご覧になれます。
    * [French](https://gist.github.com/nikitamounier/0e93eb832cf389db12f9a69da030a2dc)
    * [Indonesian](https://gist.github.com/wendyliga/792ea9ac5cc887f59de70a9e39cc7343)
    * [Italian](https://gist.github.com/Bellaposa/5114e6d4d55fdb1388e8186886d48958)
    * [Japanese](https://gist.github.com/kalupas226/bdf577e4a7066377ea0a8aaeebcad428)
    * [Korean](https://gist.github.com/pilgwon/ea05e2207ab68bdd1f49dff97b293b17)
    * [Portuguese](https://gist.github.com/SevioCorrea/2bbf337cd084a58c89f2f7f370626dc8)
    * [Simplified Chinese](https://gist.github.com/sh3l6orrr/10c8f7c634a892a9c37214f3211242ad)
    * [Japanese](https://gist.github.com/kalupas226/bdf577e4a7066377ea0a8aaeebcad428)
    * [Spanish](https://gist.github.com/pitt500/f5e32fccb575ce112ffea2827c7bf942)

    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [open a PR](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) してください!

    ## FAQ

    * The Composable Architecture は Elm や Redux などと比較してどうなのでしょうか?
    <details>
    <summary>答えを見るために展開する</summary>
    The Composable Architecture (TCA) は、Elm Architecture (TEA) と Redux で広まったアイデアを基礎に、Swift 言語と Apple のプラットフォームで快適に動作するように作られています。

    ある意味、TCA は他のライブラリよりも少し意見が強いと言えます。例えば、Redux は副作用の実行方法について規定がありませんが、TCA は全ての副作用を `Effect` 型でモデル化し、Reducer から返すことを要求しています。

    他の点では、TCA は他のライブラリよりも少し緩いと言えます。例えば Elm は `Cmd` 型を介してどのような種類の Effect を作成できるかを制御しますが、TCA では `Effect` が Combine `Publisher` protocol に準拠しているため、どのような種類の Effect にもすることが可能です。

    そして、Redux や Elm、あるいは他のほとんどのライブラリでは重視されない、TCA が非常に優先していることがあるのです。例えば、コンポジションは TCA にとって非常に重要な側面であり、大きな機能をより小さな Unit に分解し、それを繋げるプロセスです。これは Reducer の `pullback``combine` operator で実現され、複雑な機能の処理と、より分離されたコードベースとコンパイル時間の改善のためのモジュール化を支援します。
    </details>

    ## Credits と thanks

    初期の頃のライブラリにご意見をいただき、現在のライブラリの姿になったのは、以下の方々のおかげです。
  8. kalupas226 revised this gist Aug 20, 2022. 1 changed file with 45 additions and 68 deletions.
    113 changes: 45 additions & 68 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -103,18 +103,17 @@ enum AppAction: Equatable {
    case decrementButtonTapped
    case incrementButtonTapped
    case numberFactButtonTapped
    case numberFactResponse(Result<String, ApiError>)
    case numberFactResponse(TaskResult<String>)
    }

    struct ApiError: Error, Equatable {}
    ```

    次に、この機能が動作するために必要な依存関係の Environment をモデル化します。特に、数に関する事実を取得するためには、ネットワークリクエストをカプセル化した `Effect` の値を作成する必要があります。この依存関係は、`Int` から `Effect<String, ApiError>` への関数であり、`String` はリクエストからのレスポンスを表します。さらに Effect は通常バックグランドスレッドで処理を行うため (`URLSession` の場合と同様) 、メインキューで Effect の値を受け取る方法が必要です。これはメインキューの Scheduler によって行われます。これは、テストを書きやすくするために制御しておくことが重要な依存関係です。本番環境では live の `DispatchQueue` を、テスト環境ではテスト用の Scheduler を使用できるよう、`AnyScheduler` を使用しなければなりません
    次に、この機能が動作するために必要な依存関係の Environment をモデル化します。特に、`numberFact` を取得するために `Int` から `String` への async throwing function をモデル化することができます

    ```swift
    struct AppEnvironment {
    var mainQueue: AnySchedulerOf<DispatchQueue>
    var numberFact: (Int) -> Effect<String, ApiError>
    var numberFact: (Int) async throws -> String
    }
    ```

    @@ -136,9 +135,9 @@ let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, e
    return .none

    case .numberFactButtonTapped:
    return environment.numberFact(state.count)
    .receive(on: environment.mainQueue)
    .catchToEffect(AppAction.numberFactResponse)
    return .task {
    await .numberFactResponse(TaskResult { try await environment.numberFact(state.count) })
    }

    case let .numberFactResponse(.success(fact)):
    state.numberFactAlert = fact
    @@ -251,38 +250,46 @@ struct FactAlert: Identifiable {
    ```
    </details>

    この View を表示する準備ができたら、例えば Scene delegate で Store を構築することができます。これは依存関係を提供する必要がある瞬間ですが、今はモックされた string を即座に return する Effect を使用すれば良いだけです
    この View を表示する準備ができたら、例えばアプリのエントリーポイントで Store を構築することができます。この時、fact を取得するために実際に実世界の API にアクセスする `numberFact` endpoint などの依存関係を提供する必要があります

    ```swift
    let appView = AppView(
    store: Store(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(
    mainQueue: .main,
    numberFact: { number in Effect(value: "\(number) is a good number Brent") }
    @main
    struct CaseStudiesApp: App {
    var body: some Scene {
    AppView(
    store: Store(
    initialState: AppState(),
    reducer: apReducer,
    environment: AppEnvironment(
    numberFact: { number in
    let (data, _) = try await URLSession.shared
    .data(from: .init(string: "http://numbersapi.com/\(number)")!)
    return String(decoding: data, using: UTF8.self)
    }
    )
    )
    )
    )
    )
    }
    }
    ```

    そしてそれは、Screen 上で実装していく方法を得るために十分です。素の SwiftUI の方法でこれを行う場合よりも、確かにいくつかのステップを必要としますが、いくつかの利点があります。いくつかの Observable な Object や UI Component のさまざまな Action closure でロジックを散乱させる代わりに、State の変更を適用するための一貫した方法を提供します。また、副作用を簡潔に表現することができます。そして、このロジックは Effect を含め、すぐにテストすることができます。

    ### テスト

    テストを行うには、まず通常の `Store` を作成するのと同じ情報を使って `TestStore` を作成します。ただし今回はテストに適した依存関係を提供することができます。特に live の `DispatchQueue.main` Scheduler ではなく、テスト用の Scheduler を使用することで、処理を実行するタイミングを制御でき、キューが追いつくのを人為的に待つ必要がなくなるからです
    テストを行うには、まず通常の `Store` を作成するのと同じ情報を使って `TestStore` を作成します。ただし、今回はテストに適した依存関係を提供することができます。特に`numberFact` の実装では、実世界にアクセスするのではなく、私たちがコントロールできる値を即座に返すことができるようになりました

    ```swift
    let mainQueue = DispatchQueue.test

    let store = TestStore(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(
    mainQueue: mainQueue.eraseToAnyScheduler(),
    numberFact: { number in Effect(value: "\(number) is a good number Brent") }
    @MainActor
    func testFeature() async {
    let store = TestStore(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(
    numberFact: { "\($0) is a good number Brent" }
    )
    )
    )
    }
    ```

    Test store を作成したら、それを使ってユーザーフロー全体のステップを assertion することができます。各ステップごとに、State が期待通りに変化したことを証明する必要があります。さらに、あるステップで Effect が実行され、それが Store にデータをフィードバックする場合、それらの Action が適切に受信されたことを保証する必要があります。
    @@ -291,24 +298,24 @@ Test store を作成したら、それを使ってユーザーフロー全体の

    ```swift
    // インクリメント/デクリメントボタンをタップするとカウントが変化することを確認する
    store.send(.incrementButtonTapped) {
    await store.send(.incrementButtonTapped) {
    $0.count = 1
    }
    store.send(.decrementButtonTapped) {
    await store.send(.decrementButtonTapped) {
    $0.count = 0
    }

    // fact ボタンをタップすると、Effect からレスポンスが返ってくることをテストします。注意
    // reducer で `.receive(on:)` を使っているため、Scheduler を advance させなければならないことに注意してください。
    store.send(.numberFactButtonTapped)
    // Effect は非同期であるため receive を await する必要があります。
    // 実際に値が放出されるのに少量の時間がかかるからです。
    await store.send(.numberFactButtonTapped)

    mainQueue.advance()
    store.receive(.numberFactResponse(.success("0 is a good number Brent"))) {
    await store.receive(.numberFactResponse(.success("0 is a good number Brent"))) {
    $0.numberFactAlert = "0 is a good number Brent"
    }

    // And finally dismiss the alert
    store.send(.factAlertDismissed) {
    await store.send(.factAlertDismissed) {
    $0.numberFactAlert = nil
    }
    ```
    @@ -367,39 +374,6 @@ The Composable Architecture の最も重要な原則の一つは、副作用は
    そして、Redux や Elm、あるいは他のほとんどのライブラリでは重視されない、TCA が非常に優先していることがあるのです。例えば、コンポジションは TCA にとって非常に重要な側面であり、大きな機能をより小さな Unit に分解し、それを繋げるプロセスです。これは Reducer の `pullback` と `combine` operator で実現され、複雑な機能の処理と、より分離されたコードベースとコンパイル時間の改善のためのモジュール化を支援します。
    </details>

    * なぜ `Store` はスレッドセーフではないのですか? <br> なぜ `send` はキューに入らないのですか? <br> なぜ `send` はメインスレッドで実行されないのですか?
    <details>
    <summary>答えを見るために展開する</summary>

    `Store` のインスタンス (全てのスコープと派生した `ViewStore` を含む) との全てのインタラクションは同じスレッドで行われなければなりません。Store が SwiftUI や UIKit の View を駆動している場合、全てのインタラクションは _main_thread で実行されなければなりません。

    Action が `Store` に送られると、現在の State に対して Reducer が実行され、この処理は複数のスレッドから実行することはできません。回避策として、`send` の実装でキューを使用することが考えられますが、これにはいくつかの新しい複雑な問題が発生します。

    1. もし単純に `DispatchQueue.main.async` で実行すると、すでにメインスレッドにいる時でもスレッドホップが発生します。これは UIKit や SwiftUI において、animation block のように同期的に作業を行う必要がある場合に、予期しない動作につながることがあります。

    2. メインスレッドでは即座に処理を実行し、それ以外では `DispatchQueue.main.async` を使用する Scheduler を作成することができます。 (_e.g._ [CombineScheduler](https://github.com/pointfreeco/combine-schedulers) の [`UIScheduler`](https://github.com/pointfreeco/combine-schedulers/blob/main/Sources/CombineSchedulers/UIScheduler.swift) を参照してください)。これは、より多くの複雑さをもたらすので、おそらく非常に良い理由がない限り、採用されるべきではないでしょう。

    これが、全ての Action が同じスレッドから送られることを要求する理由です。この要件は `URLSession` や他の Apple API がどのように設計されているかと同じ精神に基づいています。これらの API は、自分にとって最も便利なスレッドで出力を行う傾向があり、その後それが必要であればメインキューにディスパッチバックするのはあなたの責任です。The Composable Architecture は、メインスレッドで Action を送信することを確認する責任をあなたに負わせます。もし、メインスレッドではないスレッドで出力を行う可能性のある Effect を使用している場合、メインスレッドに強制的に戻すために明示的に `.receive(on:)` を実行しなければなりません。

    この方法は、Effect の生成と変換について最も少ない仮定を立て、不要なスレッドホップや再ディスパッチを防ぎます。また、テストの面でも利点があります。Effect が自分自身のスケジューリングに責任を持たない場合、テストでは全ての Effect が同期してすぐに実行されます。そうすると、複数の実行中の Effect が互いに影響し合って、アプリケーションの State にどのような影響を与えるかをテストすることができません。しかし、スケジューリングを `Store` から切り離すことで、必要であれば Effect のこれらの側面をテストすることができますし、必要であれば無視することもできます。私たちにはその柔軟性があります。

    しかし、もしあなたがまだ私たちの選択を好まないのであれば、心配しないでください!The Composable Architecture は柔軟性に富んでいるので、あなたが望めばこの機能を自分で導入することができます。Effect がどこで処理を行うかにかかわらず、全ての Effect の出力をメインスレッドで行うように強制できる higher-order reducer を作成することが可能です。

    ```swift
    extension Reducer {
    func receive<S: Scheduler>(on scheduler: S) -> Self {
    Self { state, action, environment in
    self(&state, action, environment)
    .receive(on: scheduler)
    .eraseToEffect()
    }
    }
    }
    ```

    スレッドホップを不必要に行わないようにするために、`UIScheduler` のようなものがきっと必要になるでしょう。
    </details>

    ## 利用するために必要な要件

    The Composable Architecture は Combine フレームワークに依存しているため、最低でも iOS 13, macOS 10.15, Mac Catalyst 13, tvOS 13, watchOS 6 のデプロイメントターゲットが必要です。どうしても古い OS に対応したい場合は、[ReactiveSwift](https://github.com/trading-point/reactiveswift-composable-architecture) や [RxSwift](https://github.com/dannyhertz/rxswift-composable-architecture) の fork がありますので、そちらを採用してください!
    @@ -419,12 +393,15 @@ The Composable Architecture は package の依存関係として追加するこ
    releases と `main` のドキュメントはこちらでご覧になれます。

    * [`main`](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture)
    * [0.36.0](https://pointfreeco.github.io/swift-composable-architecture/0.36.0/documentation/composablearchitecture)
    * [0.39.0](https://pointfreeco.github.io/swift-composable-architecture/0.39.0/documentation/composablearchitecture/)
    <details>
    <summary>
    他のバージョン
    </summary>

    * [0.38.0](https://pointfreeco.github.io/swift-composable-architecture/0.38.0/documentation/composablearchitecture/)
    * [0.37.0](https://pointfreeco.github.io/swift-composable-architecture/0.37.0/documentation/composablearchitecture)
    * [0.36.0](https://pointfreeco.github.io/swift-composable-architecture/0.36.0/documentation/composablearchitecture)
    * [0.35.0](https://pointfreeco.github.io/swift-composable-architecture/0.35.0/documentation/composablearchitecture)
    * [0.34.0](https://pointfreeco.github.io/swift-composable-architecture/0.34.0/documentation/composablearchitecture)
    * [0.33.1](https://pointfreeco.github.io/swift-composable-architecture/0.33.1/documentation/composablearchitecture)
  9. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -521,4 +521,4 @@ The Composable Architecture は、他のライブラリ、特に [Elm](https://e

    ## License

    本ライブラリは、MIT ライセンスで公開されています。詳しくは [LICENSE](LICENSE) をご覧ください。
    本ライブラリは、MIT ライセンスで公開されています。詳しくは [LICENSE](https://github.com/pointfreeco/swift-composable-architecture/blob/main/LICENSE) をご覧ください。
  10. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@

    The Composable Architecture (省略すると TCA) は、コンポジション、テスト、開発者にとっての使いやすさを考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用できます。

    * [The Composable Architecture とは何か?](#The-Composable-Architecture とは何か?)
    * [The Composable Architecture とは何か?](#The-Composable-Architecture-とは何か?)
    * [もっと学ぶために](#もっと学ぶために)
    * [利用例](#利用例)
    * [基本的な利用方法](#基本的な利用方法)
    @@ -17,7 +17,7 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    * [ドキュメント](#ドキュメント)
    * [ヘルプ](#ヘルプ)
    * [翻訳](#翻訳)
    * [Credits と thanks](#Creditsthanks)
    * [Credits と thanks](#Credits-と-thanks)
    * [他のライブラリ](#他のライブラリ)

    ## The Composable Architecture とは何か?
  11. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@

    The Composable Architecture (省略すると TCA) は、コンポジション、テスト、開発者にとっての使いやすさを考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用できます。

    * [The Composable Architecture とは何か?](#The-Composable-Architecture-とは何か?)
    * [The Composable Architecture とは何か?](#The-Composable-Architecture とは何か?)
    * [もっと学ぶために](#もっと学ぶために)
    * [利用例](#利用例)
    * [基本的な利用方法](#基本的な利用方法)
    @@ -16,8 +16,8 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    * [インストール方法](#インストール方法)
    * [ドキュメント](#ドキュメント)
    * [ヘルプ](#ヘルプ)
    * [有志による翻訳](#有志による翻訳)
    * [Credits と thanks](#Credits-と-thanks)
    * [翻訳](#翻訳)
    * [Credits と thanks](#Creditsthanks)
    * [他のライブラリ](#他のライブラリ)

    ## The Composable Architecture とは何か?
  12. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,9 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    * [利用するために必要な要件](#利用するために必要な要件)
    * [インストール方法](#インストール方法)
    * [ドキュメント](#ドキュメント)
    * [Help](#help)
    * [ヘルプ](#ヘルプ)
    * [有志による翻訳](#有志による翻訳)
    * [Credits and thanks](#credits-and-thanks)
    * [Credits thanks](#Credits-と-thanks)
    * [他のライブラリ](#他のライブラリ)

    ## The Composable Architecture とは何か?
    @@ -471,7 +471,7 @@ releases と `main` のドキュメントはこちらでご覧になれます。
    * [0.1.0](https://pointfreeco.github.io/swift-composable-architecture/0.1.0/documentation/composablearchitecture)
    </details>

    ## Help
    ## ヘルプ

    もし、The Composable Architecture について議論したい、または特定の問題を解決するために TCA をどのように使用するかについて質問がある場合、このリポジトリの [discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) タブでトピックを立ち上げるか、[its Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture) で質問することができます。

    @@ -489,7 +489,7 @@ releases と `main` のドキュメントはこちらでご覧になれます。

    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [open a PR](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) してください!

    ## Credits and thanks
    ## Credits thanks

    初期の頃のライブラリにご意見をいただき、現在のライブラリの姿になったのは、以下の方々のおかげです。

  13. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -52,23 +52,23 @@ The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw

    ## 利用例

    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](./Examples)
    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples)

    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す数多くのサンプルが含まれています。この [Examples](./Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。
    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す数多くのサンプルが含まれています。この [Exampleshttps://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。

    * [Case Studies](./Examples/CaseStudies)
    * [Case Studies](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/CaseStudies)
    * Getting started
    * Effects
    * Navigation
    * Higher-order reducers
    * Reusable components
    * [Location manager](https://github.com/pointfreeco/composable-core-location/tree/main/Examples/LocationManager)
    * [Motion manager](https://github.com/pointfreeco/composable-core-motion/tree/main/Examples/MotionManager)
    * [Search](./Examples/Search)
    * [Speech Recognition](./Examples/SpeechRecognition)
    * [Tic-Tac-Toe](./Examples/TicTacToe)
    * [Todos](./Examples/Todos)
    * [Voice memos](./Examples/VoiceMemos)
    * [Search](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/Search)
    * [Speech Recognition](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/SpeechRecognition)
    * [Tic-Tac-Toe](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/TicTacToe)
    * [Todos](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/Todos)
    * [Voice memos](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/VoiceMemos)

    もっと充実したものをお探しですか? SwiftUI と The Composable Architecture で作られた iOS の単語検索ゲームである [isowords](https://github.com/pointfreeco/isowords) のソースコードをチェックしてみてください。

    @@ -313,7 +313,7 @@ store.send(.factAlertDismissed) {
    }
    ```

    これが The Composable Architecture の機能を構築し、テストするための基本です。コンポジション、モジュール化、適応性、複雑な Effect など、探究すべきことはもっとたくさんあります。[Examples](./Examples) ディレクトリには、より高度な使い方を見るためのプロジェクトがたくさんあります。
    これが The Composable Architecture の機能を構築し、テストするための基本です。コンポジション、モジュール化、適応性、複雑な Effect など、探究すべきことはもっとたくさんあります。[Examples](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples) ディレクトリには、より高度な使い方を見るためのプロジェクトがたくさんあります。

    ### デバッグ

    @@ -412,7 +412,7 @@ The Composable Architecture は package の依存関係として追加するこ
    2. package リポジトリの URL のテキストフィールドに "https://github.com/pointfreeco/swift-composable-architecture" を入力します。
    3. プロジェクトの構成によって異なります。
    - もしライブラリにアクセスする必要がある単一のアプリケーションターゲットがある場合、アプリケーションに直接 **ComposableArchitecture** を追加してください。
    - もし複数の Xcode ターゲットからこのライブラリを使用したい場合、または Xcode ターゲットと SPM ターゲットを混在させたい場合は **ComposableArchitecture** に依存する共有フレームワークを作成し、全てのターゲットでそのフレームワークに依存する必要があります。この例として、[Tic-Tac-Toe](./Examples/TicTacToe) デモアプリケーションをチェックしてください。これは多くの機能をモジュールに分割し、**tic-tac-toe** Swift package を使用してこの方法で静的ライブラリを使用しています。
    - もし複数の Xcode ターゲットからこのライブラリを使用したい場合、または Xcode ターゲットと SPM ターゲットを混在させたい場合は **ComposableArchitecture** に依存する共有フレームワークを作成し、全てのターゲットでそのフレームワークに依存する必要があります。この例として、[Tic-Tac-Toe](https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples/TicTacToe) デモアプリケーションをチェックしてください。これは多くの機能をモジュールに分割し、**tic-tac-toe** Swift package を使用してこの方法で静的ライブラリを使用しています。

    ## ドキュメント

  14. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 16 additions and 15 deletions.
    31 changes: 16 additions & 15 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -416,13 +416,13 @@ The Composable Architecture は package の依存関係として追加するこ

    ## ドキュメント

    The documentation for releases and `main` are available here:
    releases `main` のドキュメントはこちらでご覧になれます。

    * [`main`](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture)
    * [0.36.0](https://pointfreeco.github.io/swift-composable-architecture/0.36.0/documentation/composablearchitecture)
    <details>
    <summary>
    Other versions
    他のバージョン
    </summary>

    * [0.35.0](https://pointfreeco.github.io/swift-composable-architecture/0.35.0/documentation/composablearchitecture)
    @@ -473,36 +473,37 @@ The documentation for releases and `main` are available here:

    ## Help

    If you want to discuss the Composable Architecture or have a question about how to use it to solve a particular problem, you can start a topic in the [discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) tab of this repo, or ask around on [its Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture).
    もし、The Composable Architecture について議論したい、または特定の問題を解決するために TCA をどのように使用するかについて質問がある場合、このリポジトリの [discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) タブでトピックを立ち上げるか、[its Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture) で質問することができます。

    ## Translations
    ## 翻訳

    The following translations of this README have been contributed by members of the community:
    この README の以下の翻訳は、コミュニティのメンバーによって寄稿されたものです。

    * [Arabic](https://gist.github.com/NorhanBoghdadi/1b98d55c02b683ddef7e05c2ebcccd47)
    * [French](https://gist.github.com/nikitamounier/0e93eb832cf389db12f9a69da030a2dc)
    * [Indonesian](https://gist.github.com/wendyliga/792ea9ac5cc887f59de70a9e39cc7343)
    * [Italian](https://gist.github.com/Bellaposa/5114e6d4d55fdb1388e8186886d48958)
    * [Korean](https://gist.github.com/pilgwon/ea05e2207ab68bdd1f49dff97b293b17)
    * [Simplified Chinese](https://gist.github.com/sh3l6orrr/10c8f7c634a892a9c37214f3211242ad)
    * [Japanese](https://gist.github.com/kalupas226/bdf577e4a7066377ea0a8aaeebcad428)

    If you'd like to contribute a translation, please [open a PR](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) with a link to a [Gist](https://gist.github.com)!
    もし翻訳を提供したい場合は、[Gist](https://gist.github.com) へのリンクを添えて [open a PR](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) してください!

    ## Credits and thanks

    The following people gave feedback on the library at its early stages and helped make the library what it is today:
    初期の頃のライブラリにご意見をいただき、現在のライブラリの姿になったのは、以下の方々のおかげです。

    Paul Colton, Kaan Dedeoglu, Matt Diephouse, Josef Doležal, Eimantas, Matthew Johnson, George Kaimakas, Nikita Leonov, Christopher Liscio, Jeffrey Macko, Alejandro Martinez, Shai Mishali, Willis Plummer, Simon-Pierre Roy, Justin Price, Sven A. Schmidt, Kyle Sherman, Petr Šíma, Jasdev Singh, Maxim Smirnov, Ryan Stone, Daniel Hollis Tavares, and all of the [Point-Free](https://www.pointfree.co) subscribers 😁.
    Paul Colton, Kaan Dedeoglu, Matt Diephouse, Josef Doležal, Eimantas, Matthew Johnson, George Kaimakas, Nikita Leonov, Christopher Liscio, Jeffrey Macko, Alejandro Martinez, Shai Mishali, Willis Plummer, Simon-Pierre Roy, Justin Price, Sven A. Schmidt, Kyle Sherman, Petr Šíma, Jasdev Singh, Maxim Smirnov, Ryan Stone, Daniel Hollis Tavares, そして [Point-Free](https://www.pointfree.co) subscribers 全ての人たち 😁.

    Special thanks to [Chris Liscio](https://twitter.com/liscio) who helped us work through many strange SwiftUI quirks and helped refine the final API.
    多くの奇妙な SwiftUI の癖を解決し、最終的な API を洗練するのを助けてくれた [Chris Liscio](https://twitter.com/liscio) に特別な感謝を捧げます。

    And thanks to [Shai Mishali](https://github.com/freak4pc) and the [CombineCommunity](https://github.com/CombineCommunity/CombineExt/) project, from which we took their implementation of `Publishers.Create`, which we use in `Effect` to help bridge delegate and callback-based APIs, making it much easier to interface with 3rd party frameworks.
    そして [Shai Mishali](https://github.com/freak4pc) [CombineCommunity](https://github.com/CombineCommunity/CombineExt/) プロジェクトのおかげで、`Publishers.Create` の実装を取得できました。この実装は `Effect` で使用して、delegate callback ベースの API をブリッジングし、サードパーティのフレームワークとのインターフェースをより簡単にするために役立ちます。

    ## Other libraries
    ## 他のライブラリ

    The Composable Architecture was built on a foundation of ideas started by other libraries, in particular [Elm](https://elm-lang.org) and [Redux](https://redux.js.org/).
    The Composable Architecture は、他のライブラリ、特に [Elm](https://elm-lang.org) [Redux](https://redux.js.org/) によって始められたアイデアの基礎の上に構築されています。

    There are also many architecture libraries in the Swift and iOS community. Each one of these has their own set of priorities and trade-offs that differ from the Composable Architecture.
    また、Swift iOS のコミュニティには、多くのアーキテクチャライブラリが存在します。これらはそれぞれ The Composable Architecture とは異なる優先順位やトレードオフの設定を持っています。

    * [RIBs](https://github.com/uber/RIBs)
    * [Loop](https://github.com/ReactiveCocoa/Loop)
    @@ -512,12 +513,12 @@ There are also many architecture libraries in the Swift and iOS community. Each
    * [RxFeedback](https://github.com/NoTests/RxFeedback.swift)
    * [Mobius.swift](https://github.com/spotify/mobius.swift)
    * <details>
    <summary>And more</summary>
    <summary>もっと見る</summary>

    * [Fluxor](https://github.com/FluxorOrg/Fluxor)
    * [PromisedArchitectureKit](https://github.com/RPallas92/PromisedArchitectureKit)
    </details>

    ## License

    This library is released under the MIT license. See [LICENSE](LICENSE) for details.
    本ライブラリは、MIT ライセンスで公開されています。詳しくは [LICENSE](LICENSE) をご覧ください。
  15. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 26 additions and 26 deletions.
    52 changes: 26 additions & 26 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -355,35 +355,35 @@ The Composable Architecture の最も重要な原則の一つは、副作用は

    ## FAQ

    * How does the Composable Architecture compare to Elm, Redux, and others?
    * The Composable Architecture ElmRedux などと比較してどうなのでしょうか?
    <details>
    <summary>Expand to see answer</summary>
    The Composable Architecture (TCA) is built on a foundation of ideas popularized by the Elm Architecture (TEA) and Redux, but made to feel at home in the Swift language and on Apple's platforms.
    <summary>答えを見るために展開する</summary>
    The Composable Architecture (TCA) は、Elm Architecture (TEA) Redux で広まったアイデアを基礎に、Swift 言語と Apple のプラットフォームで快適に動作するように作られています。

    In some ways TCA is a little more opinionated than the other libraries. For example, Redux is not prescriptive with how one executes side effects, but TCA requires all side effects to be modeled in the `Effect` type and returned from the reducer.
    ある意味、TCA は他のライブラリよりも少し意見が強いと言えます。例えば、Redux は副作用の実行方法について規定がありませんが、TCA は全ての副作用を `Effect` 型でモデル化し、Reducer から返すことを要求しています。

    In other ways TCA is a little more lax than the other libraries. For example, Elm controls what kinds of effects can be created via the `Cmd` type, but TCA allows an escape hatch to any kind of effect since `Effect` conforms to the Combine `Publisher` protocol.
    他の点では、TCA は他のライブラリよりも少し緩いと言えます。例えば Elm `Cmd` 型を介してどのような種類の Effect を作成できるかを制御しますが、TCA では `Effect` Combine `Publisher` protocol に準拠しているため、どのような種類の Effect にもすることが可能です。

    And then there are certain things that TCA prioritizes highly that are not points of focus for Redux, Elm, or most other libraries. For example, composition is very important aspect of TCA, which is the process of breaking down large features into smaller units that can be glued together. This is accomplished with the `pullback` and `combine` operators on reducers, and it aids in handling complex features as well as modularization for a better-isolated code base and improved compile times.
    そして、Redux や Elm、あるいは他のほとんどのライブラリでは重視されない、TCA が非常に優先していることがあるのです。例えば、コンポジションは TCA にとって非常に重要な側面であり、大きな機能をより小さな Unit に分解し、それを繋げるプロセスです。これは Reducer の `pullback` `combine` operator で実現され、複雑な機能の処理と、より分離されたコードベースとコンパイル時間の改善のためのモジュール化を支援します。
    </details>

    * Why isn't `Store` thread-safe? <br> Why isn't `send` queued? <br> Why isn't `send` run on the main thread?
    * なぜ `Store` はスレッドセーフではないのですか? <br> なぜ `send` はキューに入らないのですか? <br> なぜ `send` はメインスレッドで実行されないのですか?
    <details>
    <summary>Expand to see answer</summary>
    <summary>答えを見るために展開する</summary>

    All interactions with an instance of `Store` (including all of its scopes and derived `ViewStore`s) must be done on the same thread. If the store is powering a SwiftUI or UIKit view then, all interactions must be done on the _main_ thread.
    `Store` のインスタンス (全てのスコープと派生した `ViewStore` を含む) との全てのインタラクションは同じスレッドで行われなければなりません。Store が SwiftUI UIKit の View を駆動している場合、全てのインタラクションは _main_thread で実行されなければなりません。

    When an action is sent to the `Store`, a reducer is run on the current state, and this process cannot be done from multiple threads. A possible work around is to use a queue in `send`s implementation, but this introduces a few new complications:
    Action が `Store` に送られると、現在の State に対して Reducer が実行され、この処理は複数のスレッドから実行することはできません。回避策として、`send` の実装でキューを使用することが考えられますが、これにはいくつかの新しい複雑な問題が発生します。

    1. If done simply with `DispatchQueue.main.async` you will incur a thread hop even when you are already on the main thread. This can lead to unexpected behavior in UIKit and SwiftUI, where sometimes you are required to do work synchronously, such as in animation blocks.
    1. もし単純に `DispatchQueue.main.async` で実行すると、すでにメインスレッドにいる時でもスレッドホップが発生します。これは UIKit SwiftUI において、animation block のように同期的に作業を行う必要がある場合に、予期しない動作につながることがあります。

    2. It is possible to create a scheduler that performs its work immediately when on the main thread and otherwise uses `DispatchQueue.main.async` (_e.g._ see [CombineScheduler](https://github.com/pointfreeco/combine-schedulers)'s [`UIScheduler`](https://github.com/pointfreeco/combine-schedulers/blob/main/Sources/CombineSchedulers/UIScheduler.swift)). This introduces a lot more complexity, and should probably not be adopted without having a very good reason.
    2. メインスレッドでは即座に処理を実行し、それ以外では `DispatchQueue.main.async` を使用する Scheduler を作成することができます。 (_e.g._ [CombineScheduler](https://github.com/pointfreeco/combine-schedulers)[`UIScheduler`](https://github.com/pointfreeco/combine-schedulers/blob/main/Sources/CombineSchedulers/UIScheduler.swift) を参照してください)。これは、より多くの複雑さをもたらすので、おそらく非常に良い理由がない限り、採用されるべきではないでしょう。

    This is why we require all actions be sent from the same thread. This requirement is in the same spirit of how `URLSession` and other Apple APIs are designed. Those APIs tend to deliver their outputs on whatever thread is most convenient for them, and then it is your responsibility to dispatch back to the main queue if that's what you need. The Composable Architecture makes you responsible for making sure to send actions on the main thread. If you are using an effect that may deliver its output on a non-main thread, you must explicitly perform `.receive(on:)` in order to force it back on the main thread.
    これが、全ての Action が同じスレッドから送られることを要求する理由です。この要件は `URLSession` や他の Apple API がどのように設計されているかと同じ精神に基づいています。これらの API は、自分にとって最も便利なスレッドで出力を行う傾向があり、その後それが必要であればメインキューにディスパッチバックするのはあなたの責任です。The Composable Architecture は、メインスレッドで Action を送信することを確認する責任をあなたに負わせます。もし、メインスレッドではないスレッドで出力を行う可能性のある Effect を使用している場合、メインスレッドに強制的に戻すために明示的に `.receive(on:)` を実行しなければなりません。

    This approach makes the fewest number of assumptions about how effects are created and transformed, and prevents unnecessary thread hops and re-dispatching. It also provides some testing benefits. If your effects are not responsible for their own scheduling, then in tests all of the effects would run synchronously and immediately. You would not be able to test how multiple in-flight effects interleave with each other and affect the state of your application. However, by leaving scheduling out of the `Store` we get to test these aspects of our effects if we so desire, or we can ignore if we prefer. We have that flexibility.
    この方法は、Effect の生成と変換について最も少ない仮定を立て、不要なスレッドホップや再ディスパッチを防ぎます。また、テストの面でも利点があります。Effect が自分自身のスケジューリングに責任を持たない場合、テストでは全ての Effect が同期してすぐに実行されます。そうすると、複数の実行中の Effect が互いに影響し合って、アプリケーションの State にどのような影響を与えるかをテストすることができません。しかし、スケジューリングを `Store` から切り離すことで、必要であれば Effect のこれらの側面をテストすることができますし、必要であれば無視することもできます。私たちにはその柔軟性があります。

    However, if you are still not a fan of our choice, then never fear! The Composable Architecture is flexible enough to allow you to introduce this functionality yourself if you so desire. It is possible to create a higher-order reducer that can force all effects to deliver their output on the main thread, regardless of where the effect does its work:
    しかし、もしあなたがまだ私たちの選択を好まないのであれば、心配しないでください!The Composable Architecture は柔軟性に富んでいるので、あなたが望めばこの機能を自分で導入することができます。Effect がどこで処理を行うかにかかわらず、全ての Effect の出力をメインスレッドで行うように強制できる higher-order reducer を作成することが可能です。

    ```swift
    extension Reducer {
    @@ -397,24 +397,24 @@ The Composable Architecture の最も重要な原則の一つは、副作用は
    }
    ```

    You would probably still want something like a `UIScheduler` so that you don't needlessly perform thread hops.
    スレッドホップを不必要に行わないようにするために、`UIScheduler` のようなものがきっと必要になるでしょう。
    </details>

    ## Requirements
    ## 利用するために必要な要件

    The Composable Architecture depends on the Combine framework, so it requires minimum deployment targets of iOS 13, macOS 10.15, Mac Catalyst 13, tvOS 13, and watchOS 6. If your application must support older OSes, there are forks for [ReactiveSwift](https://github.com/trading-point/reactiveswift-composable-architecture) and [RxSwift](https://github.com/dannyhertz/rxswift-composable-architecture) that you can adopt!
    The Composable Architecture Combine フレームワークに依存しているため、最低でも iOS 13, macOS 10.15, Mac Catalyst 13, tvOS 13, watchOS 6 のデプロイメントターゲットが必要です。どうしても古い OS に対応したい場合は、[ReactiveSwift](https://github.com/trading-point/reactiveswift-composable-architecture) [RxSwift](https://github.com/dannyhertz/rxswift-composable-architecture) の fork がありますので、そちらを採用してください!

    ## Installation
    ## インストール方法

    You can add ComposableArchitecture to an Xcode project by adding it as a package dependency.
    The Composable Architecture は package の依存関係として追加することで、Xcode プロジェクトに追加することができます。

    1. From the **File** menu, select **Add Packages...**
    2. Enter "https://github.com/pointfreeco/swift-composable-architecture" into the package repository URL text field
    3. Depending on how your project is structured:
    - If you have a single application target that needs access to the library, then add **ComposableArchitecture** directly to your application.
    - If you want to use this library from multiple Xcode targets, or mixing Xcode targets and SPM targets, you must create a shared framework that depends on **ComposableArchitecture** and then depend on that framework in all of your targets. For an example of this, check out the [Tic-Tac-Toe](./Examples/TicTacToe) demo application, which splits lots of features into modules and consumes the static library in this fashion using the **tic-tac-toe** Swift package.
    1. **File** メニューから、**Add Packages...** を選択します。
    2. package リポジトリの URL のテキストフィールドに "https://github.com/pointfreeco/swift-composable-architecture" を入力します。
    3. プロジェクトの構成によって異なります。
    - もしライブラリにアクセスする必要がある単一のアプリケーションターゲットがある場合、アプリケーションに直接 **ComposableArchitecture** を追加してください。
    - もし複数の Xcode ターゲットからこのライブラリを使用したい場合、または Xcode ターゲットと SPM ターゲットを混在させたい場合は **ComposableArchitecture** に依存する共有フレームワークを作成し、全てのターゲットでそのフレームワークに依存する必要があります。この例として、[Tic-Tac-Toe](./Examples/TicTacToe) デモアプリケーションをチェックしてください。これは多くの機能をモジュールに分割し、**tic-tac-toe** Swift package を使用してこの方法で静的ライブラリを使用しています。

    ## Documentation
    ## ドキュメント

    The documentation for releases and `main` are available here:

  16. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -341,17 +341,17 @@ The Composable Architecture には、デバッグを支援するためのツー

    <img src="https://s3.amazonaws.com/pointfreeco-production/point-free-pointers/0044-signposts-cover.jpg" width="600">

    ## Supplementary libraries
    ## 補助的なライブラリ

    One of the most important principles of the Composable Architecture is that side effects are never performed directly, but instead are wrapped in the `Effect` type, returned from reducers, and then the `Store` later performs the effect. This is crucial for simplifying how data flows through an application, and for gaining testability on the full end-to-end cycle of user action to effect execution.
    The Composable Architecture の最も重要な原則の一つは、副作用は決して直接実行されず、代わりに `Effect` 型にラップされて Reducer から return され、後で `Store` が Effect を実行することです。これはアプリケーション内のデータの流れを単純化し、ユーザーアクションから Effect の実行までの完全な E2E テスト容易性を得るために重要なことです。

    However, this also means that many libraries and SDKs you interact with on a daily basis need to be retrofitted to be a little more friendly to the Composable Architecture style. That's why we'd like to ease the pain of using some of Apple's most popular frameworks by providing wrapper libraries that expose their functionality in a way that plays nicely with our library. So far we support:
    しかし、これはあなたが日常的に使っている多くのライブラリや SDK が The Composable Architecture のスタイルにもう少しフレンドリーであるように改修する必要があることも意味しています。そういうわけで、私たちは Apple の最も人気のあるフレームワークのいくつかを、私たちのライブラリとうまく連携する方法でその機能を公開するラッパーライブラリを提供することで、The Composable Architecture 使用時の苦痛を軽減したいと思っています。今のところ、私たちは以下をサポートしています。

    * [`ComposableCoreLocation`](https://github.com/pointfreeco/composable-core-location): A wrapper around `CLLocationManager` that makes it easy to use from a reducer, and easy to write tests for how your logic interacts with `CLLocationManager`'s functionality.
    * [`ComposableCoreMotion`](https://github.com/pointfreeco/composable-core-motion): A wrapper around `CMMotionManager` that makes it easy to use from a reducer, and easy to write tests for how your logic interacts with `CMMotionManager`'s functionality.
    * More to come soon. Keep an eye out 😉
    * [`ComposableCoreLocation`](https://github.com/pointfreeco/composable-core-location): `CLLocationManager` のラッパーです。Reducer から簡単に利用することができ、あなたのアプリのロジックが `CLLocationManager` の機能とどのように相互作用するかのテストを簡単に書くことができます。
    * [`ComposableCoreMotion`](https://github.com/pointfreeco/composable-core-motion): `CMMotionManager` のラッパーです。Reducer から簡単に利用することができ、あなたのアプリのロジックが `CMMotionManager` の機能とどのように相互作用するかのテストを簡単に書くことができます。
    * より多くのラッパーは近日公開予定です。ご期待ください 😉

    If you are interested in contributing a wrapper library for a framework that we have not yet covered, feel free to open an issue expressing your interest so that we can discuss a path forward.
    もし、私たちがまだカバーしていないフレームワークのラッパーライブラリを提供することに興味があれば、遠慮なくあなたの関心を表現する issue をオープンしてください。

    ## FAQ

  17. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -266,11 +266,11 @@ let appView = AppView(
    )
    ```

    そしてそれは、Screen 上で実装するために何かを得るのに十分です。素の SwiftUI の方法でこれを行う場合よりも、確かにいくつかのステップを必要としますが、いくつかの利点があります。いくつかの Observable な Object や UI Component のさまざまな Action closure でロジックを散乱させる代わりに、State の変更を適用するための一貫した方法を提供します。また、副作用を簡潔に表現することができます。そして、このロジックは Effect を含め、すぐにテストすることができます。
    そしてそれは、Screen 上で実装していく方法を得るために十分です。素の SwiftUI の方法でこれを行う場合よりも、確かにいくつかのステップを必要としますが、いくつかの利点があります。いくつかの Observable な Object や UI Component のさまざまな Action closure でロジックを散乱させる代わりに、State の変更を適用するための一貫した方法を提供します。また、副作用を簡潔に表現することができます。そして、このロジックは Effect を含め、すぐにテストすることができます。

    ### Testing
    ### テスト

    To test, you first create a `TestStore` with the same information that you would to create a regular `Store`, except this time we can supply test-friendly dependencies. In particular, we use a test scheduler instead of the live `DispatchQueue.main` scheduler because that allows us to control when work is executed, and we don't have to artificially wait for queues to catch up.
    テストを行うには、まず通常の `Store` を作成するのと同じ情報を使って `TestStore` を作成します。ただし今回はテストに適した依存関係を提供することができます。特に live `DispatchQueue.main` Scheduler ではなく、テスト用の Scheduler を使用することで、処理を実行するタイミングを制御でき、キューが追いつくのを人為的に待つ必要がなくなるからです。

    ```swift
    let mainQueue = DispatchQueue.test
    @@ -285,21 +285,21 @@ let store = TestStore(
    )
    ```

    Once the test store is created we can use it to make an assertion of an entire user flow of steps. Each step of the way we need to prove that state changed how we expect. Further, if a step causes an effect to be executed, which feeds data back into the store, we must assert that those actions were received properly.
    Test store を作成したら、それを使ってユーザーフロー全体のステップを assertion することができます。各ステップごとに、State が期待通りに変化したことを証明する必要があります。さらに、あるステップで Effect が実行され、それが Store にデータをフィードバックする場合、それらの Action が適切に受信されたことを保証する必要があります。

    The test below has the user increment and decrement the count, then they ask for a number fact, and the response of that effect triggers an alert to be shown, and then dismissing the alert causes the alert to go away.
    以下のテストでは、ユーザーがカウントをインクリメント・デクリメントし、その後数字についての事実を尋ね、その Effect のレスポンスが Alert を表示するトリガーとなり、その後 Alert を解除すると Alert が消えることを確かめています。

    ```swift
    // Test that tapping on the increment/decrement buttons changes the count
    // インクリメント/デクリメントボタンをタップするとカウントが変化することを確認する
    store.send(.incrementButtonTapped) {
    $0.count = 1
    }
    store.send(.decrementButtonTapped) {
    $0.count = 0
    }

    // Test that tapping the fact button causes us to receive a response from the effect. Note
    // that we have to advance the scheduler because we used `.receive(on:)` in the reducer.
    // fact ボタンをタップすると、Effect からレスポンスが返ってくることをテストします。注意
    // reducer で `.receive(on:)` を使っているため、Scheduler を advance させなければならないことに注意してください。
    store.send(.numberFactButtonTapped)

    mainQueue.advance()
    @@ -313,13 +313,13 @@ store.send(.factAlertDismissed) {
    }
    ```

    That is the basics of building and testing a feature in the Composable Architecture. There are _a lot_ more things to be explored, such as composition, modularity, adaptability, and complex effects. The [Examples](./Examples) directory has a bunch of projects to explore to see more advanced usages.
    これが The Composable Architecture の機能を構築し、テストするための基本です。コンポジション、モジュール化、適応性、複雑な Effect など、探究すべきことはもっとたくさんあります。[Examples](./Examples) ディレクトリには、より高度な使い方を見るためのプロジェクトがたくさんあります。

    ### Debugging
    ### デバッグ

    The Composable Architecture comes with a number of tools to aid in debugging.
    The Composable Architecture には、デバッグを支援するためのツールが多数付属しています。

    * `reducer.debug()` enhances a reducer with debug-printing that describes every action the reducer receives and every mutation it makes to state.
    * `reducer.debug()` は、Reducer が受け取る全ての Action と State に対する全ての変更を記述する debug-printing で、Reducer を強化します。

    ``` diff
    received action:
    @@ -337,7 +337,7 @@ The Composable Architecture comes with a number of tools to aid in debugging.
      )
    ```

    * `reducer.signpost()` instruments a reducer with signposts so that you can gain insight into how long actions take to execute, and when effects are running.
    * `reducer.signpost()` は Reducer に signpost をつけて、Action の実行にかかる時間や Effect が実行されるタイミングを知ることができるようにします。

    <img src="https://s3.amazonaws.com/pointfreeco-production/point-free-pointers/0044-signposts-cover.jpg" width="600">

  18. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -185,13 +185,12 @@ struct FactAlert: Identifiable {
    }
    ```

    重要なのは
    It's important to note that we were able to implement this entire feature without having a real, live effect at hand. This is important because it means features can be built in isolation without building their dependencies, which can help compile times.
    重要なのは、この機能全体を実際に手元で Live Effect (実際のリクエスト) なしで実装できたということです。これは、依存関係を構築することなく機能を分離して構築できることを意味し、コンパイル時間の短縮に繋げることができるため重要です。

    It is also straightforward to have a UIKit controller driven off of this store. You subscribe to the store in `viewDidLoad` in order to update the UI and show alerts. The code is a bit longer than the SwiftUI version, so we have collapsed it here:
    また、この Store から UIKit の Controller を駆動させることも簡単です。UI を更新して Alert を表示するために、`viewDidLoad` で Store を subscribe すれば良いのです。コードは SwiftUI バージョンよりも少し長いため、折りたたんでいます。

    <details>
    <summary>Click to expand!</summary>
    <summary>クリックして展開してください!</summary>

    ```swift
    class AppViewController: UIViewController {
    @@ -252,7 +251,7 @@ It is also straightforward to have a UIKit controller driven off of this store.
    ```
    </details>

    Once we are ready to display this view, for example in the scene delegate, we can construct a store. This is the moment where we need to supply the dependencies, and for now we can just use an effect that immediately returns a mocked string:
    この View を表示する準備ができたら、例えば Scene delegate で Store を構築することができます。これは依存関係を提供する必要がある瞬間ですが、今はモックされた string を即座に return する Effect を使用すれば良いだけです。

    ```swift
    let appView = AppView(
    @@ -267,7 +266,7 @@ let appView = AppView(
    )
    ```

    And that is enough to get something on the screen to play around with. It's definitely a few more steps than if you were to do this in a vanilla SwiftUI way, but there are a few benefits. It gives us a consistent manner to apply state mutations, instead of scattering logic in some observable objects and in various action closures of UI components. It also gives us a concise way of expressing side effects. And we can immediately test this logic, including the effects, without doing much additional work.
    そしてそれは、Screen 上で実装するために何かを得るのに十分です。素の SwiftUI の方法でこれを行う場合よりも、確かにいくつかのステップを必要としますが、いくつかの利点があります。いくつかの Observable な Object や UI Component のさまざまな Action closure でロジックを散乱させる代わりに、State の変更を適用するための一貫した方法を提供します。また、副作用を簡潔に表現することができます。そして、このロジックは Effect を含め、すぐにテストすることができます。

    ### Testing

  19. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -151,8 +151,7 @@ let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, e
    }
    ```

    そして最後に、アプリの機能を表示する View を定義します。View では `Store<AppState, AppAction>` を保持し、State への全ての変更を observe して再レンダリングするできるようにします。また、State が変換するように、全てのユーザーの Action を Store に送ることができます。また `.alert` view modifier が必要とする `Identifiable` を実現するために、数に関する事実を表示する Alert の周りに struct のラッパーを導入する必要があります。
    And then finally we define the view that displays the feature. It holds onto a `Store<AppState, AppAction>` so that it can observe all changes to the state and re-render, and we can send all user actions to the store so that state changes. We must also introduce a struct wrapper around the fact alert to make it `Identifiable`, which the `.alert` view modifier requires:
    そして最後に、アプリの機能を表示する View を定義します。View では `Store<AppState, AppAction>` を保持し、State への全ての変更を observe して再レンダリングするできるようにします。また、State が変化するように、全てのユーザーの Action を Store に送ることができます。また `.alert` view modifier が必要とする `Identifiable` を実現するために、数に関する事実を表示する Alert の周りに struct のラッパーを導入する必要があります。

    ```swift
    struct AppView: View {
    @@ -186,6 +185,7 @@ struct FactAlert: Identifiable {
    }
    ```

    重要なのは
    It's important to note that we were able to implement this entire feature without having a real, live effect at hand. This is important because it means features can be built in isolation without building their dependencies, which can help compile times.

    It is also straightforward to have a UIKit controller driven off of this store. You subscribe to the store in `viewDidLoad` in order to update the UI and show alerts. The code is a bit longer than the SwiftUI version, so we have collapsed it here:
  20. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -95,7 +95,7 @@ struct AppState: Equatable {
    }
    ```

    Next we have the actions in the feature. There are the obvious actions, such as tapping the decrement button, increment button, or fact button. But there are also some slightly non-obvious ones, such as the action of the user dismissing the alert, and the action that occurs when we receive a response from the fact API request:
    次に、その機能における Action です。数字を減少させるボタン、増加させるボタン、または数字についての事実を表示するためのボタンをタップするような、明白な Action があります。しかし、ユーザーが Alert を解除する Action や、数字についての事実を取得するための API リクエストからレスポンスを受信した時に発生する Action など、少しわかりにくい Action もあります。

    ```swift
    enum AppAction: Equatable {
    @@ -109,7 +109,7 @@ enum AppAction: Equatable {
    struct ApiError: Error, Equatable {}
    ```

    Next we model the environment of dependencies this feature needs to do its job. In particular, to fetch a number fact we need to construct an `Effect` value that encapsulates the network request. So that dependency is a function from `Int` to `Effect<String, ApiError>`, where `String` represents the response from the request. Further, the effect will typically do its work on a background thread (as is the case with `URLSession`), and so we need a way to receive the effect's values on the main queue. We do this via a main queue scheduler, which is a dependency that is important to control so that we can write tests. We must use an `AnyScheduler` so that we can use a live `DispatchQueue` in production and a test scheduler in tests.
    次に、この機能が動作するために必要な依存関係の Environment をモデル化します。特に、数に関する事実を取得するためには、ネットワークリクエストをカプセル化した `Effect` の値を作成する必要があります。この依存関係は、`Int` から `Effect<String, ApiError>` への関数であり、`String` はリクエストからのレスポンスを表します。さらに Effect は通常バックグランドスレッドで処理を行うため (`URLSession` の場合と同様) 、メインキューで Effect の値を受け取る方法が必要です。これはメインキューの Scheduler によって行われます。これは、テストを書きやすくするために制御しておくことが重要な依存関係です。本番環境では live の `DispatchQueue` を、テスト環境ではテスト用の Scheduler を使用できるよう、`AnyScheduler` を使用しなければなりません。

    ```swift
    struct AppEnvironment {
    @@ -118,7 +118,7 @@ struct AppEnvironment {
    }
    ```

    Next, we implement a reducer that implements the logic for this domain. It describes how to change the current state to the next state, and describes what effects need to be executed. Some actions don't need to execute effects, and they can return `.none` to represent that:
    次に、このアプリのドメインロジックを実装した Reducer を実装します。現在の State を次の State に変更する方法を記述し、どのような Effect を実行する必要があるかを記述しています。Action によっては、Effect を実行する必要がないものもあるので、それを表すために `.none` を return することができます。

    ```swift
    let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, environment in
    @@ -151,6 +151,7 @@ let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, e
    }
    ```

    そして最後に、アプリの機能を表示する View を定義します。View では `Store<AppState, AppAction>` を保持し、State への全ての変更を observe して再レンダリングするできるようにします。また、State が変換するように、全てのユーザーの Action を Store に送ることができます。また `.alert` view modifier が必要とする `Identifiable` を実現するために、数に関する事実を表示する Alert の周りに struct のラッパーを導入する必要があります。
    And then finally we define the view that displays the feature. It holds onto a `Store<AppState, AppAction>` so that it can observe all changes to the state and re-render, and we can send all user actions to the store so that state changes. We must also introduce a struct wrapper around the fact alert to make it `Identifiable`, which the `.alert` view modifier requires:

    ```swift
  21. kalupas226 revised this gist Jul 2, 2022. No changes.
  22. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -76,17 +76,17 @@ The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw

    The Composable Archtiecture を使用して機能を構築するには、ドメインをモデル化するいくつかの型と値を定義します。

    * **State**: A type that describes the data your feature needs to perform its logic and render its UI.
    * **Action**: A type that represents all of the actions that can happen in your feature, such as user actions, notifications, event sources and more.
    * **Environment**: A type that holds any dependencies the feature needs, such as API clients, analytics clients, etc.
    * **Reducer**: A function that describes how to evolve the current state of the app to the next state given an action. The reducer is also responsible for returning any effects that should be run, such as API requests, which can be done by returning an `Effect` value.
    * **Store**: The runtime that actually drives your feature. You send all user actions to the store so that the store can run the reducer and effects, and you can observe state changes in the store so that you can update UI.
    * **State**: あなたのアプリの機能がロジックを実行し、UI をレンダリングするために必要なデータを記述する型です。
    * **Action**: ユーザーのアクション、通知、イベントソースなど、あなたのアプリの機能で起こりうる全てのアクションを表す型です。
    * **Environment**: API クライアントや Analytics クライアントなど、あなたのアプリの機能が必要とするあらゆる依存関係を保持する型です。
    * **Reducer**: Action が与えられた時に、アプリの現在の State を次の State に進化させる方法を記述する関数です。Reducer は API リクエストのような実行すべき Effects を return する役割も担っており、`Effect` を return することでそれを実行できます。
    * **Store**: 実際にあなたのアプリの機能を動かす runtime です。全てのユーザーアクションを Store に送信し、Store は Reducer と Effect を実行できるようにし、Store の状態変化を observe して UI を更新できるようにします。

    The benefits of doing this is that you will instantly unlock testability of your feature, and you will be able to break large, complex features into smaller domains that can be glued together.
    この方法の利点は、あなたのアプリの機能のテスタビリティを即座に解除し、大規模で複雑な機能を繋げることができる小さなドメインに分割できるようになることです。

    As a basic example, consider a UI that shows a number along with "+" and "−" buttons that increment and decrement the number. To make things interesting, suppose there is also a button that when tapped makes an API request to fetch a random fact about that number and then displays the fact in an alert.
    基本的な例として、数字と数字を増減させる「+」「-」ボタンが表示される UI を考えてみましょう。さらに面白いことに、タップすると API リクエストを行い、その数字に関するランダムな事実を取得し、その事実を Alert で表示するボタンがあるとします。

    The state of this feature would consist of an integer for the current count, as well as an optional string that represents the title of the alert we want to show (optional because `nil` represents not showing an alert):
    この機能の State は、現在のカウントを表す integer と表示したい Alert のタイトルを表す optional string で構成されます。 (`nil` は Alert を表示しないということを表すため、Alert のタイトルは optional として表現されます)

    ```swift
    struct AppState: Equatable {
  23. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -54,7 +54,7 @@ The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw

    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](./Examples)

    This repo comes with _lots_ of examples to demonstrate how to solve common and complex problems with the Composable Architecture. Check out [this](./Examples) directory to see them all, including:
    このリポジトリには、The Composable Architecture で一般的な問題や複雑な問題を解決する方法を示す数多くのサンプルが含まれています。この [Examples](./Examples) ディレクトリを checkout して、それらを全て見てください。そのディレクトリには以下が含まれています。

    * [Case Studies](./Examples/CaseStudies)
    * Getting started
    @@ -70,11 +70,11 @@ This repo comes with _lots_ of examples to demonstrate how to solve common and c
    * [Todos](./Examples/Todos)
    * [Voice memos](./Examples/VoiceMemos)

    Looking for something more substantial? Check out the source code for [isowords](https://github.com/pointfreeco/isowords), an iOS word search game built in SwiftUI and the Composable Architecture.
    もっと充実したものをお探しですか? SwiftUI と The Composable Architecture で作られた iOS の単語検索ゲームである [isowords](https://github.com/pointfreeco/isowords) のソースコードをチェックしてみてください。

    ## Basic Usage
    ## 基本的な利用方法

    To build a feature using the Composable Architecture you define some types and values that model your domain:
    The Composable Archtiecture を使用して機能を構築するには、ドメインをモデル化するいくつかの型と値を定義します。

    * **State**: A type that describes the data your feature needs to perform its logic and render its UI.
    * **Action**: A type that represents all of the actions that can happen in your feature, such as user actions, notifications, event sources and more.
  24. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,7 @@ The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0069.jpeg" width="600">
    </a>

    ## Examples
    ## 利用例

    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](./Examples)

  25. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    The Composable Architecture は [Brandon Williams](https://twitter.com/mbrandonw)[Stephen Celis](https://twitter.com/stephencelis) がホストする、関数型プログラミングと Swift 言語を探求するビデオシリーズである [Point-Free](https://www.pointfree.co) の多くのエピソードを経て設計されています。

    全エピソードは[こちら](https://www.pointfree.co/collections/composable-architecture)でご覧いただけます。また、ゼロから Architecture を学ぶいくつかのパートからなる TCA 専用のツアーもあります。
    [part 1](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep100-a-tour-of-the-composable-architecture-part-1), [part 2](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep101-a-tour-of-the-composable-architecture-part-2), [part 3](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep102-a-tour-of-the-composable-architecture-part-3) and [part 4](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep103-a-tour-of-the-composable-architecture-part-4).
    [part 1](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep100-a-tour-of-the-composable-architecture-part-1), [part 2](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep101-a-tour-of-the-composable-architecture-part-2), [part 3](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep102-a-tour-of-the-composable-architecture-part-3), [part 4](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep103-a-tour-of-the-composable-architecture-part-4).

    <a href="https://www.pointfree.co/collections/composable-architecture">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0069.jpeg" width="600">
  26. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -28,22 +28,23 @@ The Composable Architecture (省略すると TCA) は、コンポジション、
    <br> シンプルな値型を使用してアプリケーションの状態を管理し、多くの画面で状態を共有して、ある画面での状態の変更を別の画面ですぐに observe できるようにする方法。

    * **コンポジション**
    <br> 大きな機能を小さな Component 分解し、それwぞれを独立したモジュールに抽出し、簡単にそれらを繋いで機能を形成する方法。
    <br> 大きな機能を小さな Component に分解し、それぞれを独立したモジュールに抽出し、簡単にそれらを繋いで機能を形成する方法。

    * **副作用**
    <br> 可能な限りテスト可能で理解しやすい方法で、アプリケーションの特定の部分を外界と対話させる方法。

    * **Testing**
    <br> How to not only test a feature built in the architecture, but also write integration tests for features that have been composed of many parts, and write end-to-end tests to understand how side effects influence your application. This allows you to make strong guarantees that your business logic is running in the way you expect.
    * **テスト**
    <br > アーキテクチャで構築された機能をテストするだけでなく、多くの Component で構成された機能の Integration test を書いたり、副作用がアプリケーションに与える影響を理解するために E2E テストを書いたりする方法。これにより、ビジネスロジックが期待通りに動作していることを強く保証することができる。

    * **Ergonomics**
    <br> How to accomplish all of the above in a simple API with as few concepts and moving parts as possible.
    * **開発者にとっての使いやすさ**
    <br> 上記の全てを、できるだけ少ないコンセプトと動作するパーツからなるシンプルな API で実現する方法。

    ## もっと学ぶために

    The Composable Architecture was designed over the course of many episodes on [Point-Free](https://www.pointfree.co), a video series exploring functional programming and the Swift language, hosted by [Brandon Williams](https://twitter.com/mbrandonw) and [Stephen Celis](https://twitter.com/stephencelis).
    The Composable Architecture [Brandon Williams](https://twitter.com/mbrandonw) [Stephen Celis](https://twitter.com/stephencelis) がホストする、関数型プログラミングと Swift 言語を探求するビデオシリーズである [Point-Free](https://www.pointfree.co) の多くのエピソードを経て設計されています。

    You can watch all of the episodes [here](https://www.pointfree.co/collections/composable-architecture), as well as a dedicated, multipart tour of the architecture from scratch: [part 1](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep100-a-tour-of-the-composable-architecture-part-1), [part 2](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep101-a-tour-of-the-composable-architecture-part-2), [part 3](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep102-a-tour-of-the-composable-architecture-part-3) and [part 4](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep103-a-tour-of-the-composable-architecture-part-4).
    全エピソードは[こちら](https://www.pointfree.co/collections/composable-architecture)でご覧いただけます。また、ゼロから Architecture を学ぶいくつかのパートからなる TCA 専用のツアーもあります。
    [part 1](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep100-a-tour-of-the-composable-architecture-part-1), [part 2](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep101-a-tour-of-the-composable-architecture-part-2), [part 3](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep102-a-tour-of-the-composable-architecture-part-3) and [part 4](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep103-a-tour-of-the-composable-architecture-part-4).

    <a href="https://www.pointfree.co/collections/composable-architecture">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0069.jpeg" width="600">
  27. kalupas226 revised this gist Jul 2, 2022. 1 changed file with 14 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -4,34 +4,34 @@
    [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-composable-architecture%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/swift-composable-architecture)
    [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-composable-architecture%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/swift-composable-architecture)

    The Composable Architecture (省略すると TCA) は、コンポジション、テスト、人間工学を考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用できます。
    The Composable Architecture (省略すると TCA) は、コンポジション、テスト、開発者にとっての使いやすさを考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用できます。

    * [The Composable Architecture とは何か?](#The-Composable-Architecture-とは何か?)
    * [もっと学ぶために](#もっと学ぶために)
    * [利用例](#利用例)
    * [基本的な利用方法](#基本的な利用方法)
    * [Supplemental libraries](#supplementary-libraries)
    * [補助的なライブラリ](#補助的なライブラリ)
    * [FAQ](#faq)
    * [Requirements](#requirements)
    * [Installation](#installation)
    * [Documentation](#documentation)
    * [利用するために必要な要件](#利用するために必要な要件)
    * [インストール方法](#インストール方法)
    * [ドキュメント](#ドキュメント)
    * [Help](#help)
    * [Translations](#translations)
    * [有志による翻訳](#有志による翻訳)
    * [Credits and thanks](#credits-and-thanks)
    * [Other libraries](#other-libraries)
    * [他のライブラリ](#他のライブラリ)

    ## The Composable Architecture とは何か?

    This library provides a few core tools that can be used to build applications of varying purpose and complexity. It provides compelling stories that you can follow to solve many problems you encounter day-to-day when building applications, such as:
    このライブラリは、さまざまな目的や複雑さのアプリケーションを構築するために使用できる、いくつかのコアツールを提供します。アプリケーションを構築する際に日々遭遇する多くの問題を解決するために、以下のような説得力のあるストーリーが提供されています。

    * **State management**
    <br> How to manage the state of your application using simple value types, and share state across many screens so that mutations in one screen can be immediately observed in another screen.
    * **状態管理**
    <br> シンプルな値型を使用してアプリケーションの状態を管理し、多くの画面で状態を共有して、ある画面での状態の変更を別の画面ですぐに observe できるようにする方法。

    * **Composition**
    <br> How to break down large features into smaller components that can be extracted to their own, isolated modules and be easily glued back together to form the feature.
    * **コンポジション**
    <br> 大きな機能を小さな Component 分解し、それwぞれを独立したモジュールに抽出し、簡単にそれらを繋いで機能を形成する方法。

    * **Side effects**
    <br> How to let certain parts of the application talk to the outside world in the most testable and understandable way possible.
    * **副作用**
    <br> 可能な限りテスト可能で理解しやすい方法で、アプリケーションの特定の部分を外界と対話させる方法。

    * **Testing**
    <br> How to not only test a feature built in the architecture, but also write integration tests for features that have been composed of many parts, and write end-to-end tests to understand how side effects influence your application. This allows you to make strong guarantees that your business logic is running in the way you expect.
  28. kalupas226 created this gist Jul 2, 2022.
    522 changes: 522 additions & 0 deletions JapaneseTCA.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,522 @@
    # The Composable Architecture

    [![CI](https://github.com/pointfreeco/swift-composable-architecture/workflows/CI/badge.svg)](https://github.com/pointfreeco/swift-composable-architecture/actions?query=workflow%3ACI)
    [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-composable-architecture%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/swift-composable-architecture)
    [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-composable-architecture%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/swift-composable-architecture)

    The Composable Architecture (省略すると TCA) は、コンポジション、テスト、人間工学を考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用できます。

    * [The Composable Architecture とは何か?](#The-Composable-Architecture-とは何か?)
    * [もっと学ぶために](#もっと学ぶために)
    * [利用例](#利用例)
    * [基本的な利用方法](#基本的な利用方法)
    * [Supplemental libraries](#supplementary-libraries)
    * [FAQ](#faq)
    * [Requirements](#requirements)
    * [Installation](#installation)
    * [Documentation](#documentation)
    * [Help](#help)
    * [Translations](#translations)
    * [Credits and thanks](#credits-and-thanks)
    * [Other libraries](#other-libraries)

    ## The Composable Architecture とは何か?

    This library provides a few core tools that can be used to build applications of varying purpose and complexity. It provides compelling stories that you can follow to solve many problems you encounter day-to-day when building applications, such as:

    * **State management**
    <br> How to manage the state of your application using simple value types, and share state across many screens so that mutations in one screen can be immediately observed in another screen.

    * **Composition**
    <br> How to break down large features into smaller components that can be extracted to their own, isolated modules and be easily glued back together to form the feature.

    * **Side effects**
    <br> How to let certain parts of the application talk to the outside world in the most testable and understandable way possible.

    * **Testing**
    <br> How to not only test a feature built in the architecture, but also write integration tests for features that have been composed of many parts, and write end-to-end tests to understand how side effects influence your application. This allows you to make strong guarantees that your business logic is running in the way you expect.

    * **Ergonomics**
    <br> How to accomplish all of the above in a simple API with as few concepts and moving parts as possible.

    ## もっと学ぶために

    The Composable Architecture was designed over the course of many episodes on [Point-Free](https://www.pointfree.co), a video series exploring functional programming and the Swift language, hosted by [Brandon Williams](https://twitter.com/mbrandonw) and [Stephen Celis](https://twitter.com/stephencelis).

    You can watch all of the episodes [here](https://www.pointfree.co/collections/composable-architecture), as well as a dedicated, multipart tour of the architecture from scratch: [part 1](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep100-a-tour-of-the-composable-architecture-part-1), [part 2](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep101-a-tour-of-the-composable-architecture-part-2), [part 3](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep102-a-tour-of-the-composable-architecture-part-3) and [part 4](https://www.pointfree.co/collections/composable-architecture/a-tour-of-the-composable-architecture/ep103-a-tour-of-the-composable-architecture-part-4).

    <a href="https://www.pointfree.co/collections/composable-architecture">
    <img alt="video poster image" src="https://d3rccdn33rt8ze.cloudfront.net/episodes/0069.jpeg" width="600">
    </a>

    ## Examples

    [![Screen shots of example applications](https://d3rccdn33rt8ze.cloudfront.net/composable-architecture/demos.png)](./Examples)

    This repo comes with _lots_ of examples to demonstrate how to solve common and complex problems with the Composable Architecture. Check out [this](./Examples) directory to see them all, including:

    * [Case Studies](./Examples/CaseStudies)
    * Getting started
    * Effects
    * Navigation
    * Higher-order reducers
    * Reusable components
    * [Location manager](https://github.com/pointfreeco/composable-core-location/tree/main/Examples/LocationManager)
    * [Motion manager](https://github.com/pointfreeco/composable-core-motion/tree/main/Examples/MotionManager)
    * [Search](./Examples/Search)
    * [Speech Recognition](./Examples/SpeechRecognition)
    * [Tic-Tac-Toe](./Examples/TicTacToe)
    * [Todos](./Examples/Todos)
    * [Voice memos](./Examples/VoiceMemos)

    Looking for something more substantial? Check out the source code for [isowords](https://github.com/pointfreeco/isowords), an iOS word search game built in SwiftUI and the Composable Architecture.

    ## Basic Usage

    To build a feature using the Composable Architecture you define some types and values that model your domain:

    * **State**: A type that describes the data your feature needs to perform its logic and render its UI.
    * **Action**: A type that represents all of the actions that can happen in your feature, such as user actions, notifications, event sources and more.
    * **Environment**: A type that holds any dependencies the feature needs, such as API clients, analytics clients, etc.
    * **Reducer**: A function that describes how to evolve the current state of the app to the next state given an action. The reducer is also responsible for returning any effects that should be run, such as API requests, which can be done by returning an `Effect` value.
    * **Store**: The runtime that actually drives your feature. You send all user actions to the store so that the store can run the reducer and effects, and you can observe state changes in the store so that you can update UI.

    The benefits of doing this is that you will instantly unlock testability of your feature, and you will be able to break large, complex features into smaller domains that can be glued together.

    As a basic example, consider a UI that shows a number along with "+" and "−" buttons that increment and decrement the number. To make things interesting, suppose there is also a button that when tapped makes an API request to fetch a random fact about that number and then displays the fact in an alert.

    The state of this feature would consist of an integer for the current count, as well as an optional string that represents the title of the alert we want to show (optional because `nil` represents not showing an alert):

    ```swift
    struct AppState: Equatable {
    var count = 0
    var numberFactAlert: String?
    }
    ```

    Next we have the actions in the feature. There are the obvious actions, such as tapping the decrement button, increment button, or fact button. But there are also some slightly non-obvious ones, such as the action of the user dismissing the alert, and the action that occurs when we receive a response from the fact API request:

    ```swift
    enum AppAction: Equatable {
    case factAlertDismissed
    case decrementButtonTapped
    case incrementButtonTapped
    case numberFactButtonTapped
    case numberFactResponse(Result<String, ApiError>)
    }

    struct ApiError: Error, Equatable {}
    ```

    Next we model the environment of dependencies this feature needs to do its job. In particular, to fetch a number fact we need to construct an `Effect` value that encapsulates the network request. So that dependency is a function from `Int` to `Effect<String, ApiError>`, where `String` represents the response from the request. Further, the effect will typically do its work on a background thread (as is the case with `URLSession`), and so we need a way to receive the effect's values on the main queue. We do this via a main queue scheduler, which is a dependency that is important to control so that we can write tests. We must use an `AnyScheduler` so that we can use a live `DispatchQueue` in production and a test scheduler in tests.

    ```swift
    struct AppEnvironment {
    var mainQueue: AnySchedulerOf<DispatchQueue>
    var numberFact: (Int) -> Effect<String, ApiError>
    }
    ```

    Next, we implement a reducer that implements the logic for this domain. It describes how to change the current state to the next state, and describes what effects need to be executed. Some actions don't need to execute effects, and they can return `.none` to represent that:

    ```swift
    let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, environment in
    switch action {
    case .factAlertDismissed:
    state.numberFactAlert = nil
    return .none

    case .decrementButtonTapped:
    state.count -= 1
    return .none

    case .incrementButtonTapped:
    state.count += 1
    return .none

    case .numberFactButtonTapped:
    return environment.numberFact(state.count)
    .receive(on: environment.mainQueue)
    .catchToEffect(AppAction.numberFactResponse)

    case let .numberFactResponse(.success(fact)):
    state.numberFactAlert = fact
    return .none

    case .numberFactResponse(.failure):
    state.numberFactAlert = "Could not load a number fact :("
    return .none
    }
    }
    ```

    And then finally we define the view that displays the feature. It holds onto a `Store<AppState, AppAction>` so that it can observe all changes to the state and re-render, and we can send all user actions to the store so that state changes. We must also introduce a struct wrapper around the fact alert to make it `Identifiable`, which the `.alert` view modifier requires:

    ```swift
    struct AppView: View {
    let store: Store<AppState, AppAction>

    var body: some View {
    WithViewStore(self.store) { viewStore in
    VStack {
    HStack {
    Button("") { viewStore.send(.decrementButtonTapped) }
    Text("\(viewStore.count)")
    Button("+") { viewStore.send(.incrementButtonTapped) }
    }

    Button("Number fact") { viewStore.send(.numberFactButtonTapped) }
    }
    .alert(
    item: viewStore.binding(
    get: { $0.numberFactAlert.map(FactAlert.init(title:)) },
    send: .factAlertDismissed
    ),
    content: { Alert(title: Text($0.title)) }
    )
    }
    }
    }

    struct FactAlert: Identifiable {
    var title: String
    var id: String { self.title }
    }
    ```

    It's important to note that we were able to implement this entire feature without having a real, live effect at hand. This is important because it means features can be built in isolation without building their dependencies, which can help compile times.

    It is also straightforward to have a UIKit controller driven off of this store. You subscribe to the store in `viewDidLoad` in order to update the UI and show alerts. The code is a bit longer than the SwiftUI version, so we have collapsed it here:

    <details>
    <summary>Click to expand!</summary>

    ```swift
    class AppViewController: UIViewController {
    let viewStore: ViewStore<AppState, AppAction>
    var cancellables: Set<AnyCancellable> = []

    init(store: Store<AppState, AppAction>) {
    self.viewStore = ViewStore(store)
    super.init(nibName: nil, bundle: nil)
    }

    required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
    super.viewDidLoad()

    let countLabel = UILabel()
    let incrementButton = UIButton()
    let decrementButton = UIButton()
    let factButton = UIButton()

    // Omitted: Add subviews and set up constraints...

    self.viewStore.publisher
    .map { "\($0.count)" }
    .assign(to: \.text, on: countLabel)
    .store(in: &self.cancellables)

    self.viewStore.publisher.numberFactAlert
    .sink { [weak self] numberFactAlert in
    let alertController = UIAlertController(
    title: numberFactAlert, message: nil, preferredStyle: .alert
    )
    alertController.addAction(
    UIAlertAction(
    title: "Ok",
    style: .default,
    handler: { _ in self?.viewStore.send(.factAlertDismissed) }
    )
    )
    self?.present(alertController, animated: true, completion: nil)
    }
    .store(in: &self.cancellables)
    }

    @objc private func incrementButtonTapped() {
    self.viewStore.send(.incrementButtonTapped)
    }
    @objc private func decrementButtonTapped() {
    self.viewStore.send(.decrementButtonTapped)
    }
    @objc private func factButtonTapped() {
    self.viewStore.send(.numberFactButtonTapped)
    }
    }
    ```
    </details>

    Once we are ready to display this view, for example in the scene delegate, we can construct a store. This is the moment where we need to supply the dependencies, and for now we can just use an effect that immediately returns a mocked string:

    ```swift
    let appView = AppView(
    store: Store(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(
    mainQueue: .main,
    numberFact: { number in Effect(value: "\(number) is a good number Brent") }
    )
    )
    )
    ```

    And that is enough to get something on the screen to play around with. It's definitely a few more steps than if you were to do this in a vanilla SwiftUI way, but there are a few benefits. It gives us a consistent manner to apply state mutations, instead of scattering logic in some observable objects and in various action closures of UI components. It also gives us a concise way of expressing side effects. And we can immediately test this logic, including the effects, without doing much additional work.

    ### Testing

    To test, you first create a `TestStore` with the same information that you would to create a regular `Store`, except this time we can supply test-friendly dependencies. In particular, we use a test scheduler instead of the live `DispatchQueue.main` scheduler because that allows us to control when work is executed, and we don't have to artificially wait for queues to catch up.

    ```swift
    let mainQueue = DispatchQueue.test

    let store = TestStore(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(
    mainQueue: mainQueue.eraseToAnyScheduler(),
    numberFact: { number in Effect(value: "\(number) is a good number Brent") }
    )
    )
    ```

    Once the test store is created we can use it to make an assertion of an entire user flow of steps. Each step of the way we need to prove that state changed how we expect. Further, if a step causes an effect to be executed, which feeds data back into the store, we must assert that those actions were received properly.

    The test below has the user increment and decrement the count, then they ask for a number fact, and the response of that effect triggers an alert to be shown, and then dismissing the alert causes the alert to go away.

    ```swift
    // Test that tapping on the increment/decrement buttons changes the count
    store.send(.incrementButtonTapped) {
    $0.count = 1
    }
    store.send(.decrementButtonTapped) {
    $0.count = 0
    }

    // Test that tapping the fact button causes us to receive a response from the effect. Note
    // that we have to advance the scheduler because we used `.receive(on:)` in the reducer.
    store.send(.numberFactButtonTapped)

    mainQueue.advance()
    store.receive(.numberFactResponse(.success("0 is a good number Brent"))) {
    $0.numberFactAlert = "0 is a good number Brent"
    }

    // And finally dismiss the alert
    store.send(.factAlertDismissed) {
    $0.numberFactAlert = nil
    }
    ```

    That is the basics of building and testing a feature in the Composable Architecture. There are _a lot_ more things to be explored, such as composition, modularity, adaptability, and complex effects. The [Examples](./Examples) directory has a bunch of projects to explore to see more advanced usages.

    ### Debugging

    The Composable Architecture comes with a number of tools to aid in debugging.

    * `reducer.debug()` enhances a reducer with debug-printing that describes every action the reducer receives and every mutation it makes to state.

    ``` diff
    received action:
    AppAction.todoCheckboxTapped(id: UUID(5834811A-83B4-4E5E-BCD3-8A38F6BDCA90))
      AppState(
      todos: [
      Todo(
    - isComplete: false,
    + isComplete: true,
      description: "Milk",
      id: 5834811A-83B4-4E5E-BCD3-8A38F6BDCA90
      ),
      … (2 unchanged)
      ]
      )
    ```

    * `reducer.signpost()` instruments a reducer with signposts so that you can gain insight into how long actions take to execute, and when effects are running.

    <img src="https://s3.amazonaws.com/pointfreeco-production/point-free-pointers/0044-signposts-cover.jpg" width="600">

    ## Supplementary libraries

    One of the most important principles of the Composable Architecture is that side effects are never performed directly, but instead are wrapped in the `Effect` type, returned from reducers, and then the `Store` later performs the effect. This is crucial for simplifying how data flows through an application, and for gaining testability on the full end-to-end cycle of user action to effect execution.

    However, this also means that many libraries and SDKs you interact with on a daily basis need to be retrofitted to be a little more friendly to the Composable Architecture style. That's why we'd like to ease the pain of using some of Apple's most popular frameworks by providing wrapper libraries that expose their functionality in a way that plays nicely with our library. So far we support:

    * [`ComposableCoreLocation`](https://github.com/pointfreeco/composable-core-location): A wrapper around `CLLocationManager` that makes it easy to use from a reducer, and easy to write tests for how your logic interacts with `CLLocationManager`'s functionality.
    * [`ComposableCoreMotion`](https://github.com/pointfreeco/composable-core-motion): A wrapper around `CMMotionManager` that makes it easy to use from a reducer, and easy to write tests for how your logic interacts with `CMMotionManager`'s functionality.
    * More to come soon. Keep an eye out 😉

    If you are interested in contributing a wrapper library for a framework that we have not yet covered, feel free to open an issue expressing your interest so that we can discuss a path forward.

    ## FAQ

    * How does the Composable Architecture compare to Elm, Redux, and others?
    <details>
    <summary>Expand to see answer</summary>
    The Composable Architecture (TCA) is built on a foundation of ideas popularized by the Elm Architecture (TEA) and Redux, but made to feel at home in the Swift language and on Apple's platforms.

    In some ways TCA is a little more opinionated than the other libraries. For example, Redux is not prescriptive with how one executes side effects, but TCA requires all side effects to be modeled in the `Effect` type and returned from the reducer.

    In other ways TCA is a little more lax than the other libraries. For example, Elm controls what kinds of effects can be created via the `Cmd` type, but TCA allows an escape hatch to any kind of effect since `Effect` conforms to the Combine `Publisher` protocol.

    And then there are certain things that TCA prioritizes highly that are not points of focus for Redux, Elm, or most other libraries. For example, composition is very important aspect of TCA, which is the process of breaking down large features into smaller units that can be glued together. This is accomplished with the `pullback` and `combine` operators on reducers, and it aids in handling complex features as well as modularization for a better-isolated code base and improved compile times.
    </details>

    * Why isn't `Store` thread-safe? <br> Why isn't `send` queued? <br> Why isn't `send` run on the main thread?
    <details>
    <summary>Expand to see answer</summary>

    All interactions with an instance of `Store` (including all of its scopes and derived `ViewStore`s) must be done on the same thread. If the store is powering a SwiftUI or UIKit view then, all interactions must be done on the _main_ thread.

    When an action is sent to the `Store`, a reducer is run on the current state, and this process cannot be done from multiple threads. A possible work around is to use a queue in `send`s implementation, but this introduces a few new complications:

    1. If done simply with `DispatchQueue.main.async` you will incur a thread hop even when you are already on the main thread. This can lead to unexpected behavior in UIKit and SwiftUI, where sometimes you are required to do work synchronously, such as in animation blocks.

    2. It is possible to create a scheduler that performs its work immediately when on the main thread and otherwise uses `DispatchQueue.main.async` (_e.g._ see [CombineScheduler](https://github.com/pointfreeco/combine-schedulers)'s [`UIScheduler`](https://github.com/pointfreeco/combine-schedulers/blob/main/Sources/CombineSchedulers/UIScheduler.swift)). This introduces a lot more complexity, and should probably not be adopted without having a very good reason.

    This is why we require all actions be sent from the same thread. This requirement is in the same spirit of how `URLSession` and other Apple APIs are designed. Those APIs tend to deliver their outputs on whatever thread is most convenient for them, and then it is your responsibility to dispatch back to the main queue if that's what you need. The Composable Architecture makes you responsible for making sure to send actions on the main thread. If you are using an effect that may deliver its output on a non-main thread, you must explicitly perform `.receive(on:)` in order to force it back on the main thread.

    This approach makes the fewest number of assumptions about how effects are created and transformed, and prevents unnecessary thread hops and re-dispatching. It also provides some testing benefits. If your effects are not responsible for their own scheduling, then in tests all of the effects would run synchronously and immediately. You would not be able to test how multiple in-flight effects interleave with each other and affect the state of your application. However, by leaving scheduling out of the `Store` we get to test these aspects of our effects if we so desire, or we can ignore if we prefer. We have that flexibility.

    However, if you are still not a fan of our choice, then never fear! The Composable Architecture is flexible enough to allow you to introduce this functionality yourself if you so desire. It is possible to create a higher-order reducer that can force all effects to deliver their output on the main thread, regardless of where the effect does its work:

    ```swift
    extension Reducer {
    func receive<S: Scheduler>(on scheduler: S) -> Self {
    Self { state, action, environment in
    self(&state, action, environment)
    .receive(on: scheduler)
    .eraseToEffect()
    }
    }
    }
    ```

    You would probably still want something like a `UIScheduler` so that you don't needlessly perform thread hops.
    </details>

    ## Requirements

    The Composable Architecture depends on the Combine framework, so it requires minimum deployment targets of iOS 13, macOS 10.15, Mac Catalyst 13, tvOS 13, and watchOS 6. If your application must support older OSes, there are forks for [ReactiveSwift](https://github.com/trading-point/reactiveswift-composable-architecture) and [RxSwift](https://github.com/dannyhertz/rxswift-composable-architecture) that you can adopt!

    ## Installation

    You can add ComposableArchitecture to an Xcode project by adding it as a package dependency.

    1. From the **File** menu, select **Add Packages...**
    2. Enter "https://github.com/pointfreeco/swift-composable-architecture" into the package repository URL text field
    3. Depending on how your project is structured:
    - If you have a single application target that needs access to the library, then add **ComposableArchitecture** directly to your application.
    - If you want to use this library from multiple Xcode targets, or mixing Xcode targets and SPM targets, you must create a shared framework that depends on **ComposableArchitecture** and then depend on that framework in all of your targets. For an example of this, check out the [Tic-Tac-Toe](./Examples/TicTacToe) demo application, which splits lots of features into modules and consumes the static library in this fashion using the **tic-tac-toe** Swift package.

    ## Documentation

    The documentation for releases and `main` are available here:

    * [`main`](https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture)
    * [0.36.0](https://pointfreeco.github.io/swift-composable-architecture/0.36.0/documentation/composablearchitecture)
    <details>
    <summary>
    Other versions
    </summary>

    * [0.35.0](https://pointfreeco.github.io/swift-composable-architecture/0.35.0/documentation/composablearchitecture)
    * [0.34.0](https://pointfreeco.github.io/swift-composable-architecture/0.34.0/documentation/composablearchitecture)
    * [0.33.1](https://pointfreeco.github.io/swift-composable-architecture/0.33.1/documentation/composablearchitecture)
    * [0.33.0](https://pointfreeco.github.io/swift-composable-architecture/0.33.0/documentation/composablearchitecture)
    * [0.32.0](https://pointfreeco.github.io/swift-composable-architecture/0.32.0/documentation/composablearchitecture)
    * [0.31.0](https://pointfreeco.github.io/swift-composable-architecture/0.31.0/documentation/composablearchitecture)
    * [0.30.0](https://pointfreeco.github.io/swift-composable-architecture/0.30.0/documentation/composablearchitecture)
    * [0.29.0](https://pointfreeco.github.io/swift-composable-architecture/0.29.0/documentation/composablearchitecture)
    * [0.28.1](https://pointfreeco.github.io/swift-composable-architecture/0.28.1/documentation/composablearchitecture)
    * [0.28.0](https://pointfreeco.github.io/swift-composable-architecture/0.28.0/documentation/composablearchitecture)
    * [0.27.1](https://pointfreeco.github.io/swift-composable-architecture/0.27.1/documentation/composablearchitecture)
    * [0.27.0](https://pointfreeco.github.io/swift-composable-architecture/0.27.0/documentation/composablearchitecture)
    * [0.26.0](https://pointfreeco.github.io/swift-composable-architecture/0.26.0/documentation/composablearchitecture)
    * [0.25.1](https://pointfreeco.github.io/swift-composable-architecture/0.25.1/documentation/composablearchitecture)
    * [0.25.0](https://pointfreeco.github.io/swift-composable-architecture/0.25.0/documentation/composablearchitecture)
    * [0.24.0](https://pointfreeco.github.io/swift-composable-architecture/0.24.0/documentation/composablearchitecture)
    * [0.23.0](https://pointfreeco.github.io/swift-composable-architecture/0.23.0/documentation/composablearchitecture)
    * [0.22.0](https://pointfreeco.github.io/swift-composable-architecture/0.22.0/documentation/composablearchitecture)
    * [0.21.0](https://pointfreeco.github.io/swift-composable-architecture/0.21.0/documentation/composablearchitecture)
    * [0.20.0](https://pointfreeco.github.io/swift-composable-architecture/0.20.0/documentation/composablearchitecture)
    * [0.19.0](https://pointfreeco.github.io/swift-composable-architecture/0.19.0/documentation/composablearchitecture)
    * [0.18.0](https://pointfreeco.github.io/swift-composable-architecture/0.18.0/documentation/composablearchitecture)
    * [0.17.0](https://pointfreeco.github.io/swift-composable-architecture/0.17.0/documentation/composablearchitecture)
    * [0.16.0](https://pointfreeco.github.io/swift-composable-architecture/0.16.0/documentation/composablearchitecture)
    * [0.15.0](https://pointfreeco.github.io/swift-composable-architecture/0.15.0/documentation/composablearchitecture)
    * [0.14.0](https://pointfreeco.github.io/swift-composable-architecture/0.14.0/documentation/composablearchitecture)
    * [0.13.0](https://pointfreeco.github.io/swift-composable-architecture/0.13.0/documentation/composablearchitecture)
    * [0.12.0](https://pointfreeco.github.io/swift-composable-architecture/0.12.0/documentation/composablearchitecture)
    * [0.11.0](https://pointfreeco.github.io/swift-composable-architecture/0.11.0/documentation/composablearchitecture)
    * [0.10.0](https://pointfreeco.github.io/swift-composable-architecture/0.10.0/documentation/composablearchitecture)
    * [0.9.0](https://pointfreeco.github.io/swift-composable-architecture/0.9.0/documentation/composablearchitecture)
    * [0.8.0](https://pointfreeco.github.io/swift-composable-architecture/0.8.0/documentation/composablearchitecture)
    * [0.7.0](https://pointfreeco.github.io/swift-composable-architecture/0.7.0/documentation/composablearchitecture)
    * [0.6.0](https://pointfreeco.github.io/swift-composable-architecture/0.6.0/documentation/composablearchitecture)
    * [0.5.0](https://pointfreeco.github.io/swift-composable-architecture/0.5.0/documentation/composablearchitecture)
    * [0.4.0](https://pointfreeco.github.io/swift-composable-architecture/0.4.0/documentation/composablearchitecture)
    * [0.3.0](https://pointfreeco.github.io/swift-composable-architecture/0.3.0/documentation/composablearchitecture)
    * [0.2.0](https://pointfreeco.github.io/swift-composable-architecture/0.2.0/documentation/composablearchitecture)
    * [0.1.5](https://pointfreeco.github.io/swift-composable-architecture/0.1.5/documentation/composablearchitecture)
    * [0.1.4](https://pointfreeco.github.io/swift-composable-architecture/0.1.4/documentation/composablearchitecture)
    * [0.1.3](https://pointfreeco.github.io/swift-composable-architecture/0.1.3/documentation/composablearchitecture)
    * [0.1.2](https://pointfreeco.github.io/swift-composable-architecture/0.1.2/documentation/composablearchitecture)
    * [0.1.1](https://pointfreeco.github.io/swift-composable-architecture/0.1.1/documentation/composablearchitecture)
    * [0.1.0](https://pointfreeco.github.io/swift-composable-architecture/0.1.0/documentation/composablearchitecture)
    </details>

    ## Help

    If you want to discuss the Composable Architecture or have a question about how to use it to solve a particular problem, you can start a topic in the [discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) tab of this repo, or ask around on [its Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture).

    ## Translations

    The following translations of this README have been contributed by members of the community:

    * [Arabic](https://gist.github.com/NorhanBoghdadi/1b98d55c02b683ddef7e05c2ebcccd47)
    * [French](https://gist.github.com/nikitamounier/0e93eb832cf389db12f9a69da030a2dc)
    * [Indonesian](https://gist.github.com/wendyliga/792ea9ac5cc887f59de70a9e39cc7343)
    * [Italian](https://gist.github.com/Bellaposa/5114e6d4d55fdb1388e8186886d48958)
    * [Korean](https://gist.github.com/pilgwon/ea05e2207ab68bdd1f49dff97b293b17)
    * [Simplified Chinese](https://gist.github.com/sh3l6orrr/10c8f7c634a892a9c37214f3211242ad)

    If you'd like to contribute a translation, please [open a PR](https://github.com/pointfreeco/swift-composable-architecture/edit/main/README.md) with a link to a [Gist](https://gist.github.com)!

    ## Credits and thanks

    The following people gave feedback on the library at its early stages and helped make the library what it is today:

    Paul Colton, Kaan Dedeoglu, Matt Diephouse, Josef Doležal, Eimantas, Matthew Johnson, George Kaimakas, Nikita Leonov, Christopher Liscio, Jeffrey Macko, Alejandro Martinez, Shai Mishali, Willis Plummer, Simon-Pierre Roy, Justin Price, Sven A. Schmidt, Kyle Sherman, Petr Šíma, Jasdev Singh, Maxim Smirnov, Ryan Stone, Daniel Hollis Tavares, and all of the [Point-Free](https://www.pointfree.co) subscribers 😁.

    Special thanks to [Chris Liscio](https://twitter.com/liscio) who helped us work through many strange SwiftUI quirks and helped refine the final API.

    And thanks to [Shai Mishali](https://github.com/freak4pc) and the [CombineCommunity](https://github.com/CombineCommunity/CombineExt/) project, from which we took their implementation of `Publishers.Create`, which we use in `Effect` to help bridge delegate and callback-based APIs, making it much easier to interface with 3rd party frameworks.

    ## Other libraries

    The Composable Architecture was built on a foundation of ideas started by other libraries, in particular [Elm](https://elm-lang.org) and [Redux](https://redux.js.org/).

    There are also many architecture libraries in the Swift and iOS community. Each one of these has their own set of priorities and trade-offs that differ from the Composable Architecture.

    * [RIBs](https://github.com/uber/RIBs)
    * [Loop](https://github.com/ReactiveCocoa/Loop)
    * [ReSwift](https://github.com/ReSwift/ReSwift)
    * [Workflow](https://github.com/square/workflow)
    * [ReactorKit](https://github.com/ReactorKit/ReactorKit)
    * [RxFeedback](https://github.com/NoTests/RxFeedback.swift)
    * [Mobius.swift](https://github.com/spotify/mobius.swift)
    * <details>
    <summary>And more</summary>

    * [Fluxor](https://github.com/FluxorOrg/Fluxor)
    * [PromisedArchitectureKit](https://github.com/RPallas92/PromisedArchitectureKit)
    </details>

    ## License

    This library is released under the MIT license. See [LICENSE](LICENSE) for details.