LiveData 1.1.0
.NET 5.0
.NET Core 3.1
.NET Framework 4.6
dotnet add package LiveData --version 1.1.0
NuGet\Install-Package LiveData -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LiveData" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiveData --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LiveData, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LiveData as a Cake Addin
#addin nuget:?package=LiveData&version=1.1.0
// Install LiveData as a Cake Tool
#tool nuget:?package=LiveData&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LiveData
A simple android LiveData alternative for WPF and C#<br>Easily add reactive properties with a single line of code
Features
- Automatically notifies value changes
- Add reactive properties in one line
- Map LiveData values (Map)
- Convert one LiveData to another (SwitchMap)
- Combine two LiveData
- Debounce emitted values
- Delay emitted values
- Convert
Task
to LiveData
How to use
Use LiveData on your viewmodels and add reactive properties
public class MyViewModel : ViewModel {
public LiveData<string> SearchQuery { get; set; }
public LiveData<bool> IsVisible { get; set; }
public MyViewModel() {
SearchQuery = new LiveData<string>("");
SearchQuery.Value = "myname";
//React to SearchQuery changes and map the value to a boolean.
//Everything is automatically notified to the UI
IsVisible = SearchQuery.Map<bool>(it => it != "");
}
}
Transformations
//Map values to async functions
IsVisible = SearchQuery.MapAsync<bool>(it => Task.FromResult(true));
//Delay emitted values
DelayedLiveData = MyLiveData.Delay(1000);
//Debounce emitted values
Debounced = MyLiveData.Debounce(1000);
//Combine two LiveData
Combined = First.CombineWith(Second, (a, b) => a + b);
//Convert one LiveData to another LiveData
Mapped = IsVisible.SwitchMap(it => it ? SearchResultLiveData : EmptyResultLiveData);
//Concatenate transformation functions
FinalLiveData = Name.Delay(1000)
.Debounce(800)
.Map(name => "Hello" + name);
Utils
Extensions further simplify using and transforming LiveData objects.
//Convert task to LiveData
var task = Task.FromResult(true);
LiveData<bool> IsVisible = task.ToLiveData<bool>();
//Append, prepend, remove into LiveData of lists
//Changes are notified
LiveData<List<string>> Items;
Items.Remove("first");
Items.Append("first");
Items.Prepend("first");
LiveData and XAML Binding
Bind LiveData to xaml properties
<TextBlock Text="{Binding LiveData.Value}" />
📜 License
Copyright (c) 2022 Marco
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net5.0-windows7.0 net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net6.0-windows7.0 net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows net7.0-windows7.0 |
.NET Core | netcoreapp3.1 |
.NET Framework | net46 net461 net462 net463 net47 net471 net472 net48 net481 |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net5.0-windows7.0
- No dependencies.
-
net6.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New transformation functions (Delay, Debounce, CombineWith, SwitchMap) and improved memory usage