Skip to content

Commit da5fcde

Browse files
authored
Update readme file.
1 parent f0c575b commit da5fcde

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ A package that brings data-binding to your Unity project.
1818
- [Property](#propertyt--readonlypropertyt)
1919
- [Command](#command--commandt)
2020
- [AsyncCommand](#asynccommand--asynccommandt)
21-
- [AsyncLazyCommand](#asynclazycommand--asynclazycommandt)
2221
- [PropertyValueConverter](#propertyvalueconvertertsourcetype-ttargettype)
2322
- [ParameterValueConverter](#parametervalueconverterttargettype)
2423
- [Quick start](#watch-quick-start)
@@ -198,7 +197,6 @@ The included types are:
198197
- [Property\<T\> & ReadOnlyProperty\<T\>](#propertyt--readonlypropertyt)
199198
- [Command & Command\<T\>](#command--commandt)
200199
- [AsyncCommand & AsyncCommand\<T\>](#asynccommand--asynccommandt)
201-
- [AsyncLazyCommand & AsyncLazyCommand\<T\>](#asynclazycommand--asynclazycommandt)
202200
- [PropertyValueConverter\<TSourceType, TTargetType\>](#propertyvalueconvertertsourcetype-ttargettype)
203201
- [ParameterValueConverter\<TTargetType\>](#parametervalueconverterttargettype)
204202
- [IProperty\<T\> & IReadOnlyProperty\<T\>](#propertyt--readonlypropertyt)
@@ -425,6 +423,18 @@ public class ImageViewerViewModel : IBindingContext
425423
}
426424
```
427425

426+
To allow the same async command to be invoked concurrently multiple times, set the `AllowConcurrency` property of the `AsyncCommand` to `true`.
427+
428+
```csharp
429+
public class MainViewModel : IBindingContext
430+
{
431+
public MainViewModel()
432+
{
433+
RunConcurrentlyCommand = new AsyncCommand(RunConcurrentlyAsync) { AllowConcurrency = true };
434+
}
435+
}
436+
```
437+
428438
If you want to create an async command that supports cancellation, use the `WithCancellation` extension method.
429439

430440
```csharp
@@ -446,22 +456,13 @@ public class MyViewModel : IBindingContext
446456

447457
private void Cancel()
448458
{
449-
// If the underlying command is not running, or
450-
// if it does not support cancellation, this method will perform no action.
459+
// If the underlying command is not running, this method will perform no action.
451460
MyAsyncCommand.Cancel();
452461
}
453462
}
454463
```
455464

456-
If the command supports cancellation, previous invocations will automatically be canceled if a new one is started.
457-
458-
> **Note:** You need to import the [UniTask](https://github.com/Cysharp/UniTask) package in order to use async commands.
459-
460-
### AsyncLazyCommand & AsyncLazyCommand\<T\>
461-
462-
The `AsyncLazyCommand` and `AsyncLazyCommand<T>` are have the same functionality as the `AsyncCommand`'s, except they prevent the same async command from being invoked concurrently multiple times.
463-
464-
Let's imagine a scenario similar to the one described in the `AsyncCommand` sample, but a user clicks the `Download Image` button several times while the async operation is running. In this case, `AsyncLazyCommand` will ignore all clicks until previous async operation has completed.
465+
If a command supports cancellation and the `AllowConcurrency` property is set to `true`, all running commands will be canceled.
465466

466467
> **Note:** You need to import the [UniTask](https://github.com/Cysharp/UniTask) package in order to use async commands.
467468

0 commit comments

Comments
 (0)