You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an example of how to implement notification support to a custom property:
228
+
Here's an example of how to implement notification support to a custom property.
222
229
223
230
```csharp
224
231
public class CounterViewModel : ViewModel
@@ -237,7 +244,7 @@ The provided `Set<T>(ref T, T, string)` method checks the current value of the p
237
244
238
245
#### Wrapping a model
239
246
240
-
To inject notification support to models, that don't implement the `INotifyPropertyChanged` interface, `ViewModel` provides a dedicated `Set<TModel, T>(T, T, TModel, Action<TModel, T>, string)` method for this:
247
+
To inject notification support to models, that don't implement the `INotifyPropertyChanged` interface, `ViewModel` provides a dedicated `Set<TModel, T>(T, T, TModel, Action<TModel, T>, string)` method for this.
@@ -386,10 +389,10 @@ The `AsyncCommand` and `AsyncCommand<T>` are `ICommand` implementations that ext
386
389
387
390
Key functionality:
388
391
- Extend the functionalities of the synchronous commands included in the package, with support for UniTask-returning delegates
389
-
- Can wrap asynchronous functions with a `CancellationToken` parameter to support cancelation, and they implement a `DisableOnExecution`logic
392
+
- Can wrap asynchronous functions with a `CancellationToken` parameter to support cancelation, and they expose a `DisableOnExecution`property, as well as a `Cancel` method
390
393
- Implement the `IAsyncCommand` & `IAsyncCommand<T>` interfaces, which allows to replace a command with a custom implementation, if needed
391
394
392
-
Let's say we want to download an image from the web and display it as soon as it downloads:
395
+
Let's say we want to download an image from the web and display it as soon as it downloads.
393
396
394
397
```csharp
395
398
publicclassImageViewerViewModel : ViewModel
@@ -418,7 +421,7 @@ public class ImageViewerViewModel : ViewModel
// if it does not support cancellation, this method will perform no action.
466
+
MyAsyncCommand.Cancel();
467
+
}
446
468
}
447
469
```
448
470
471
+
If the command supports cancellation, previous invocations will automatically be canceled if a new one is started.
472
+
449
473
> **Note:** You need to import the [UniTask](https://github.com/Cysharp/UniTask) package in order to use async commands.
450
474
451
475
### AsyncLazyCommand & AsyncLazyCommand\<T\>
452
476
453
-
The `AsyncLazyCommand` and `AsyncLazyCommand<T>` are have the same functionality as the `AsyncCommand`'s, except they prevent the async operation from being run multiple times.
477
+
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.
454
478
455
-
Let's imagine a scenario similar to the one described in the `AsyncCommand` sample, but a user clicks the `Download Image` button several times during the async operation is running. In this case, `AsyncLazyCommand` will ignore all clicks until previous async operation has completed.
479
+
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.
456
480
457
481
> **Note:** You need to import the [UniTask](https://github.com/Cysharp/UniTask) package in order to use async commands.
458
482
@@ -462,11 +486,144 @@ Let's imagine a scenario similar to the one described in the `AsyncCommand` samp
Property value converters provide a way to apply custom logic to a property binding.
490
+
491
+
Built-in property value converters:
492
+
- IntToStrConverter
493
+
- FloatToStrConverter
494
+
495
+
If you want to create your own property value converter, create a class that inherits the `PropertyValueConverter<TSourceType, TTargetType>` abstract class and then implement the `Convert` and `ConvertBack` methods.
If you want to create your own parameter value converter, create a class that inherits the `ParameterValueConverter<TTargetType>` abstract class and then implement the `Convert` method.
@@ -688,9 +841,7 @@ public class ImageViewerView : DocumentView<ImageViewerViewModel>
688
841
689
842
```xml
690
843
<UXML>
691
-
...
692
844
<BindableImagebinding-image-path="Image" />
693
-
...
694
845
</UXML>
695
846
```
696
847
@@ -702,15 +853,15 @@ To enable [async commands](#asynccommand--asynccommandt) support, you need to ad
702
853
703
854
In addition to async commands **UnityMvvmToolkit** provides extensions to make [USS transition's](https://docs.unity3d.com/Manual/UIE-Transitions.html) awaitable.
704
855
705
-
For example, your `VisualElement` has the following transitions:
856
+
For example, your `VisualElement` has the following transitions.
706
857
```css
707
858
.panel--animation {
708
859
transition-property: opacity, padding-bottom;
709
860
transition-duration: 65ms, 150ms;
710
861
}
711
862
```
712
863
713
-
You can `await` these transitions using several methods:
864
+
You can `await` these transitions using several methods.
0 commit comments