Skip to content

Commit

Permalink
Merge pull request #219 from runceel/main
Browse files Browse the repository at this point in the history
v7.6.0
  • Loading branch information
runceel authored Jan 13, 2021
2 parents fd67265 + 72d01b2 commit db9e993
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.402
- name: Setup MSBuild.exe
uses: warrenbuckley/Setup-MSBuild@v1
dotnet-version: 3.1.*
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Update version number
if: github.ref != 'refs/heads/release'
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
npm run docs:build
working-directory: docs
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.6.1
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core-unit-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.402
dotnet-version: 3.1.*
- name: Install dependencies
run: dotnet restore ReactiveProperty.sln
- name: Test
Expand Down
17 changes: 12 additions & 5 deletions Source/ReactiveProperty.NETStandard/AsyncReactiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public AsyncReactiveCommand(IReactiveProperty<bool> sharedCanExecute)
/// <summary>
/// Push null to subscribers.
/// </summary>
public void Execute()
{
Execute(null);
}
public void Execute() => Execute(null);

/// <summary>
/// Push null to subscribers.
/// </summary>
public Task ExecuteAsync() => ExecuteAsync(null);

/// <summary>
/// Subscribe execute.
Expand Down Expand Up @@ -146,7 +148,12 @@ bool ICommand.CanExecute(object parameter)
/// <summary>
/// Push parameter to subscribers, when executing CanExecuting is changed to false.
/// </summary>
public async void Execute(T parameter)
public async void Execute(T parameter) => await ExecuteAsync(parameter);

/// <summary>
/// Push parameter to subscribers, when executing CanExecuting is changed to false.
/// </summary>
public async Task ExecuteAsync(T parameter)
{
if (isCanExecute)
{
Expand Down
3 changes: 2 additions & 1 deletion Source/SharedProperties.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<RootNamespace>Reactive.Bindings</RootNamespace>
<Version>7.5.1</Version>
<Version>7.6.0</Version>
<Authors>neuecc xin9le okazuki</Authors>
<PackageProjectUrl>https://github.com/runceel/ReactiveProperty</PackageProjectUrl>
<PackageTags>rx mvvm async rx-main reactive</PackageTags>
Expand All @@ -15,6 +15,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Include="../../Assets/ReactivePropertyIcon_100x100.png" LinkBase="Assets" Pack="true" PackagePath="/" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@ namespace ReactiveProperty.Tests
[TestClass]
public class AsyncReactiveCommandTest
{
[TestMethod]
public void ExecuteAsync()
{
var tcs = new TaskCompletionSource<bool>();
var cmd = new AsyncReactiveCommand().WithSubscribe(async () =>
{
await tcs.Task;
});

Task taskForExecuteAsync = cmd.ExecuteAsync();

taskForExecuteAsync.IsCompleted.IsFalse();
tcs.SetResult(true);
taskForExecuteAsync.IsCompleted.IsTrue();
}

[TestMethod]
public void ExecuteAsyncForGeneric()
{
var tcs = new TaskCompletionSource<bool>();
var expectedCommandParameter = new object();
var actualCommandParameter = default(object);
var cmd = new AsyncReactiveCommand<object>().WithSubscribe(async x =>
{
actualCommandParameter = x;
await tcs.Task;
});

Task taskForExecuteAsync = cmd.ExecuteAsync(expectedCommandParameter);

taskForExecuteAsync.IsCompleted.IsFalse();
tcs.SetResult(true);
taskForExecuteAsync.IsCompleted.IsTrue();
actualCommandParameter.IsSameReferenceAs(expectedCommandParameter);
}

[TestMethod]
public void DefaultUseCase()
{
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
{ text: 'Universal Windows Platform', link: '/getting-started/uwp.html' },
{ text: 'Xamarin.Forms', link: '/getting-started/xf.html' },
{ text: 'Avalonia', link: '/getting-started/avalonia.html' },
{ text: 'Uno Platform', link: '/getting-started/uno-platform.html' },
{ text: 'Add code snippets', link: '/getting-started/add-snippets.html' },
]
},
Expand Down Expand Up @@ -46,4 +47,4 @@ module.exports = {
editLinks: true,
editLinkText: 'Help us improve this document!',
}
}
}
1 change: 1 addition & 0 deletions docs/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ You can start using ReactiveProperty from the following links.
- [Windows Presentation Foundation](getting-started/wpf.md)
- [Universal Windows Platform](getting-started/uwp.md)
- [Xamarin.Forms](getting-started/xf.md)
- [Uno Platform](getting-started/uno-platform.md)

And learn the core features on following links.

Expand Down
12 changes: 11 additions & 1 deletion docs/docs/features/Notifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ n.Value = true; // true
n.Value = false; // false
```

It can use to source of `ReactiveCommand`.
It can use as source of `ReactiveCommand` like below:

```csharp
var n = new BooleanNotifier(); // the default value is false.
// CanExecute method of ReactiveCommand returns true as default. So, you set initialValue explicitly to `n.Value`.
var command = n.ToReactiveCommand(initialValue: n.Value);

// Or if you would like to convert to something using Select and others before calling ToReactiveCommand, you can use StartWith.
var command2 = n.StartWith(n.Value).Select(x => Something(x)).ToReactiveCommand();
```

## `CountNotifier`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ namespace ReactivePropertyEduApp

### Nested property path

`ObserveProperty`, `ToReactivePropertyAsSynchronized` and `ToReactivePropertySlimAsSynchronized` support to nested property path like `x => x.Child.Name`.
`ObserveProperty`, `ToReactivePropertyAsSynchronized`, `ToReactivePropertySlimAsSynchronized` and `FromObject` support to nested property path like `x => x.Child.Name`.
Suppose the value of any property in the path is null. In that case, ReactiveProperty is set `default(T)` to Value property (this is a case of to ReactiveProperty from source property), and ReactiveProperty stops synchronization to the source property (this is a case of to source property from ReactiveProperty).

After the value is updated to not null value, ReactiveProperty re-start synchronization.
After the value is updated to not null value, ReactiveProperty re-start synchronization.
6 changes: 3 additions & 3 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.402"
"version": "3.1.*"
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "2.0.54"
Expand Down

0 comments on commit db9e993

Please sign in to comment.