Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ struct CounterView: View {

### Result-Returning Actions

Actions can return results through `ActionTask`. This enables parent-child result passing and allows navigation with a navigator from @Environment, keeping everything within the view tree.
Actions can return results through `ActionTask`. The result type (`ActionResult`) can be freely defined for each Feature.

In this example, a child view returns a selection result to the parent, which handles navigation:

```swift
struct ChildSelectFeature: Feature {
Expand Down Expand Up @@ -158,8 +160,11 @@ struct ParentView: View {
}
```

- Parent-child result passing stays within the view tree
- Navigation possible with navigator from @Environment
This implementation provides:
- `ChildFeature` returns selection results to the parent via `ActionResult`
- `ParentView` receives results through the `onSelect` callback
- Parent controls side effects like navigation
- Everything stays within the view tree, making dependencies easy to track

### @Observable Support

Expand Down
11 changes: 8 additions & 3 deletions README_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ struct CounterView: View {

### 結果を返すアクション

アクションは`ActionTask`を通じて結果を返せます。これにより、親子間での結果の受け渡しが可能になります。また、結果を受け取った後に@Environmentから取得したnavigatorで画面遷移することで、すべてがビューツリー内で完結します。
アクションは`ActionTask`を通じて結果を返せます。結果の型(`ActionResult`)は各Featureで自由に定義できます。

この例では、子ビューが選択結果を親に返し、親が画面遷移を処理します:

```swift
struct ChildSelectFeature: Feature {
Expand Down Expand Up @@ -156,8 +158,11 @@ struct ParentView: View {
}
```

- 親子間での結果の受け渡しがビューツリー内で完結
- @Environmentから取得したnavigatorで画面遷移が可能
この実装により:
- `ChildFeature`が`ActionResult`を通じて選択結果を親に返す
- `ParentView`が`onSelect`コールバックで結果を受け取る
- 親が画面遷移などの副作用を制御
- すべてがビューツリー内で完結し、依存関係が追跡しやすい

### @Observable準拠

Expand Down
Loading