Skip to content

Commit d3471c7

Browse files
runceelkaota_microsoftCopilot
authored
Proofread English docs and add Japanese translations (#560)
* Proofread English docs and add Japanese docs - Improve English wording across docs/docs Markdown pages. - Add mirrored Japanese Markdown translations under docs/docs-ja. - Keep VuePress configuration and npm scripts unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Link README to repository docs - Replace the old Qiita Japanese link with docs/docs-ja. - Point documentation links to Markdown files in this repository. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Kazuki Ota <117221407+kaota_microsoft@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 23a0773 commit d3471c7

43 files changed

Lines changed: 4394 additions & 350 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[Japanese](https://qiita.com/okazuki/items/7572f46848d0e93516b1)
1+
[日本語ドキュメント](docs/docs-ja/README.md)
22

33
# ReactiveProperty
44

@@ -43,7 +43,7 @@ public class MainPageViewModel
4343

4444
It is really simple and understandable (I think!). Because there are NOT any base classes and interfaces. Just has declarative code between Input property and Output property.
4545

46-
All steps are written in the "Getting Started" section in the [ReactiveProperty documentation](https://github.com/runceel/ReactiveProperty/tree/main/docs).
46+
All steps are written in the "Getting Started" section in the [ReactiveProperty documentation](docs/docs/README.md).
4747

4848
The concept of ReactiveProperty is simple that is a core class what name is `ReactiveProperty[Slim]`, it is just a wrap class what has a value, and implements `IObservable<T>` and `INotifyPropertyChanged`, `IObservable<T>` is for connect change event of the property value to Rx LINQ method chane, `INotifyPropertyChanged` is for data binding system such as WPF, WinUI and MAUI.
4949

@@ -142,7 +142,8 @@ ReactiveProperty doesn't provide base class by ViewModel, which means that React
142142

143143
## Documentation
144144

145-
[ReactiveProperty documentation](https://github.com/runceel/ReactiveProperty/tree/main/docs)
145+
- [ReactiveProperty documentation](docs/docs/README.md)
146+
- [日本語ドキュメント](docs/docs-ja/README.md)
146147

147148
## NuGet packages
148149

docs/docs-ja/README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# ReactiveProperty とは
2+
3+
ReactiveProperty は Reactive Extensions 向けに MVVM と非同期処理を支援する機能を提供します。ターゲット フレームワークは .NET Standard 2.0 です。
4+
5+
![概要](../docs/images/rpsummary.png)
6+
7+
ReactiveProperty のコンセプトは <b>楽しいプログラミング</b> です。
8+
ReactiveProperty を使うと MVVM アプリケーションを記述できます。とても楽しいですよ!
9+
10+
![UWP](../docs/images/launch-uwp-app.gif)
11+
12+
次のコードは、ReactiveProperty と通常のオブジェクト プロパティの間の双方向バインディングを示しています。
13+
14+
```csharp
15+
class Model : INotifyPropertyChanged
16+
{
17+
public event PropertyChangedEventHandler PropertyChanged;
18+
19+
private string _name;
20+
public string Name
21+
{
22+
get => _name;
23+
set
24+
{
25+
_name = value;
26+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));
27+
}
28+
}
29+
}
30+
class ViewModel
31+
{
32+
private readonly Model _model = new Model();
33+
public ReactiveProperty<string> Name { get; }
34+
public ViewModel()
35+
{
36+
// ReactiveProperty と Model#Name プロパティの双方向同期。
37+
Name = _model.ToReactivePropertyAsSynchronized(x => x.Name);
38+
}
39+
}
40+
```
41+
42+
ReactiveProperty は `IObservable<T>` を通じて実装されています。そうです!LINQ を使えます。
43+
44+
```csharp
45+
var name = new ReactiveProperty<string>();
46+
name.Where(x => x.StartsWith("_")) // フィルター
47+
.Select(x => x.ToUpper()) // 変換
48+
.Subscribe(x => { ... 何らかの処理 ... });
49+
```
50+
51+
ReactiveProperty は `IObservable<T>` から作成されます。
52+
53+
```csharp
54+
class ViewModel
55+
{
56+
public ReactiveProperty<string> Input { get; }
57+
public ReactiveProperty<string> Output { get; }
58+
59+
public ViewModel()
60+
{
61+
Input = new ReactiveProperty("");
62+
Output = Input
63+
.Delay(TimeSpan.FromSeconds(1)) // Rx メソッドを使用。
64+
.Select(x => x.ToUpper()) // LINQ メソッドを使用。
65+
.ToReactiveProperty(); // ReactiveProperty に変換
66+
}
67+
}
68+
```
69+
70+
このメソッド チェーンはとてもクールです。
71+
72+
`ICommand``IObservable<T>` インターフェイスを実装する `ReactiveCommand` クラスも提供しています。`ReactiveCommand``IObservable<bool>` から作成できます。
73+
次のサンプルでは、`Input` プロパティが空でないときに実行できる `ReactiveCommand` を作成します。
74+
75+
```csharp
76+
class ViewModel
77+
{
78+
public ReactiveProperty<string> Input { get; }
79+
public ReactiveProperty<string> Output { get; }
80+
81+
public ReactiveCommand ResetCommand { get; }
82+
83+
public ViewModel()
84+
{
85+
Input = new ReactiveProperty("");
86+
// 上のサンプルと同じ
87+
Output = Input
88+
.Delay(TimeSpan.FromSeconds(1)) // Rx メソッドを使用。
89+
.Select(x => x.ToUpper()) // LINQ メソッドを使用。
90+
.ToReactiveProperty(); // ReactiveProperty に変換
91+
92+
ResetCommand = Input.Select(x => !string.IsNullOrWhiteSpace(x)) // ReactiveProperty<string> を IObservable<bool> に変換
93+
.ToReactiveCommand() // IObservable<bool> から ReactiveCommand を作成できます。true 値が発行されると、コマンドを実行できます。
94+
.WithSubscribe(() => Input.Value = ""); // ResetCommand.Subscribe(() => ...) のショートカットです。
95+
}
96+
}
97+
```
98+
99+
クールです!本当に宣言的で分かりやすいです。
100+
101+
## 始めましょう!
102+
103+
ReactiveProperty は次のリンクから使い始めることができます。
104+
105+
- [Windows Presentation Foundation](getting-started/wpf.md)
106+
- [Universal Windows Platform](getting-started/uwp.md)
107+
- [Xamarin.Forms](getting-started/xf.md)
108+
- [Uno Platform](getting-started/uno-platform.md)
109+
110+
コア機能については、次のリンクで学べます。
111+
112+
- [ReactiveProperty](features/ReactiveProperty.md)
113+
- [コマンド](features/Commanding.md)
114+
- [コレクション](features/Collections.md)
115+
116+
117+
## NuGet パッケージ
118+
119+
|パッケージ ID|バージョンとダウンロード数|説明|
120+
|----|----|----|
121+
|ReactiveProperty|![](https://img.shields.io/nuget/v/ReactiveProperty.svg)![](https://img.shields.io/nuget/dt/ReactiveProperty.svg)|すべてのコア機能が含まれ、ターゲット プラットフォームは .NET Standard 2.0 です。ほぼすべての状況に適しています。|
122+
|ReactiveProperty.Core|![](https://img.shields.io/nuget/v/ReactiveProperty.Core.svg)![](https://img.shields.io/nuget/dt/ReactiveProperty.Core.svg)|`ReactivePropertySlim<T>``ReadOnlyReactivePropertySlim<T>` など、最小限のクラスが含まれます。System.Reactive にも依存しません。Rx 機能が不要な場合に適しています。|
123+
|ReactiveProperty.WPF|![](https://img.shields.io/nuget/v/ReactiveProperty.WPF.svg)![](https://img.shields.io/nuget/dt/ReactiveProperty.WPF.svg)|WPF 向けの EventToReactiveProperty と EventToReactiveCommand が含まれます。.NET Core 3.0 以降および .NET Framework 4.7.2 以降向けです。|
124+
|ReactiveProperty.UWP|![](https://img.shields.io/nuget/v/ReactiveProperty.UWP.svg)![](https://img.shields.io/nuget/dt/ReactiveProperty.UWP.svg)|UWP 向けの EventToReactiveProperty と EventToReactiveCommand が含まれます。|
125+
|ReactiveProperty.XamarinAndroid|![](https://img.shields.io/nuget/v/ReactiveProperty.XamarinAndroid.svg)![](https://img.shields.io/nuget/dt/ReactiveProperty.XamarinAndroid.svg)|Xamarin.Android ネイティブのイベントから IObservable インスタンスを作成するための多くの拡張メソッドが含まれます。|
126+
|ReactiveProperty.XamariniOS|![](https://img.shields.io/nuget/v/ReactiveProperty.XamariniOS.svg)![](https://img.shields.io/nuget/dt/ReactiveProperty.XamariniOS.svg)|ReactiveProperty と ReactiveCommand を Xamarin.iOS ネイティブ コントロールにバインドするための多くの拡張メソッドが含まれます。|

docs/docs-ja/advanced/awaitable.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Awaitable
2+
3+
`ReactiveProperty``ReactivePropertySlim` を含む)、`ReadOnlyReactiveProperty``ReadOnlyReactivePropertySlim` を含む)、`ReactiveCommand` では `await` 演算子を使用できます。
4+
`await` 演算子を使用すると、次の値が発行されるまでプログラムは待機します。
5+
6+
## 例:
7+
8+
```csharp
9+
// CancellationTokenSource を持つ View
10+
public partial class SampleWindow : Window
11+
{
12+
CancellationTokenSource cts;
13+
SampleViewModel viewModel;
14+
15+
public SampleWindow()
16+
{
17+
InitializeComponent();
18+
cts = new CancellationTokenSource();
19+
viewModel = new SampleViewModel(cts.Token);
20+
}
21+
22+
protected override void OnClosed(EventArgs e)
23+
{
24+
// 終了時に、すべての await をキャンセルします。
25+
cts.Cancel();
26+
cts.Dispose();
27+
28+
base.OnClosed(e);
29+
}
30+
}
31+
32+
// CancellationToken を持つ ViewModel
33+
public class SampleViewModel
34+
{
35+
public ReactiveCommand MyCommand { get; private set; }
36+
public ReactiveProperty<int> ClickCount { get; private set; }
37+
38+
public SampleViewModel(CancellationToken closeToken)
39+
{
40+
MyCommand = new ReactiveCommand();
41+
ClickCount = new ReactiveProperty<int>();
42+
43+
// async/await でイベントを処理します。
44+
SubscribeAsync(closeToken);
45+
}
46+
47+
async void SubscribeAsync(CancellationToken closeToken)
48+
{
49+
using (var handler = MyCommand.GetAsyncHandler(closeToken))
50+
{
51+
while (true)
52+
{
53+
await handler; // クリックされるまで await します。
54+
ClickCount.Value += 1;
55+
}
56+
}
57+
}
58+
}
59+
```
60+
61+
複数回 await する場合は、`GetAsyncHandler` から `ObservableAsyncHandler<T>` を取得してください。これは割り当てなしで複数回 await できます。1 回だけ await する場合は、`await command.WaitUntilValueChangedAsync(token)` を使用できます。
62+
63+
> 注: `ReactiveProperty` を直接 await することもできますが、`GetAsyncHandler`(複数回の await)または `WaitUntilValueChangedAsync`(1 回限り)を使用し、`CancellationToken` を渡すことを推奨します。

0 commit comments

Comments
 (0)