RxUI.MauiToolkit 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package RxUI.MauiToolkit --version 1.1.1
NuGet\Install-Package RxUI.MauiToolkit -Version 1.1.1
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="RxUI.MauiToolkit" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RxUI.MauiToolkit --version 1.1.1
#r "nuget: RxUI.MauiToolkit, 1.1.1"
#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 RxUI.MauiToolkit as a Cake Addin
#addin nuget:?package=RxUI.MauiToolkit&version=1.1.1

// Install RxUI.MauiToolkit as a Cake Tool
#tool nuget:?package=RxUI.MauiToolkit&version=1.1.1

RxUI.MauiToolkit

Toolkit genérico usando ReactiveUI con clases base, helpers, servicios y controles típicos en proyectos.

Inicialización

Para inicializar el paquete usamos .InitRxToolkit(), que encontraremos en el namespace RxUI.MauiToolkit.Configuration, como método de extensión de MauiAppBuilder cuando creamos nuestra MauiApp:

public static MauiApp CreateMauiApp()
{
	var builder = MauiApp.CreateBuilder()
			     .UseMauiApp<App>()
			     .InitRxToolkit();
	...

	return builder.Build();
}

Esto añadirá los target Debug y Console al servicio de Log, así como la inicialización del resto de servicios del Nuget.

ViewModels

Este NuGet está a favor de evitar el uso de Reflection en la inyección de dependencias (siempre que sea posible). Para facilitar su construcción en el Func<IServiceProvider, TService> implementationFactory, los constructores de RxBaseViewModel, RxBasePageViewModel y RxBaseContentPage<TViewModel> no pide por inyección distintos servicios, sino el IServiceProvider para poder resolverlos él evitando la construcción por tipos.

Por ejemplo:

  • Registro de nuestro ViewModel:
// yes
builder.Services.AddTransient(s => new LoginViewModel(s));

// no
builder.Services.AddTransient<LoginViewModel>();
  • Constructor de nuestro ViewModel:
public LoginViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
{
}

El uso de RxBaseContentPage<TViewModel> exige el registro del ViewModel en el IServiceProvider.

Log

Para que nos lleguen las analíticas a AppCenter, debemos indicarles las keys de la app en AppCenter. Este proceso se hace comunmente en el OnStart() de App.xaml.cs. Para ello, resolvemos ILogService en el constructor:

public partial class App : Application
{
	private readonly ILogService logService;

	public App(ILogService logService)
	{
		this.logService = logService;
		...
	}

Y sobreescribimos el método OnStart() indicando nuestras claves:

protected override void OnStart()
{
	base.OnStart();
	logService.SetAppCenterId("[iosId]", "[androidId]", "[uwpId]", "[macosId]"); ;
}

Como ya se ha comentado, el servicio de log ya configura los target Debug y Console, pero puede añadir otros mediante los NuGets de Microsoft.Extensions.Logging

LoadingService

El servicio de loading está diseñado para gestionar las tareas de forma independiente en cada ViewModel. Se recomienda resolver el servicio bajo la categoría del ViewModel tanto en la View, como en el ViewModel. Constructores de ejemplo:

public LoginViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
{
	loadingService = serviceProvider.GetRequiredService<ILoadingService<LoginViewModel>>();
}
public LoginPage(IServiceProvider serviceProvider) : base(serviceProvider)
{
	loadingService = serviceProvider.GetRequiredService<ILoadingService<LoginViewModel>>();

	InitializeComponent();
}

De esta forma ambos estaría usando la misma instancia del servicio, pero se crearían nuevas para distintas pantallas o controles. Esta misma resolución puede hacerse con ILoadingService<TCategory>. También podemos resolver el servicio sin párametro genérico y usaríamos la misma instancia en toda la aplicación.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-android31.0 is compatible.  net6.0-ios was computed.  net6.0-ios15.4 is compatible.  net6.0-maccatalyst was computed.  net6.0-maccatalyst15.4 is compatible.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows10.0.19041 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 533 10/12/2022
1.2.1 404 10/11/2022
1.2.0 406 10/9/2022
1.1.1 401 10/6/2022
1.0.41 409 10/3/2022
1.0.40 402 10/3/2022
1.0.39 399 10/3/2022
1.0.38 401 10/3/2022
1.0.0 446 10/3/2022
0.1.0 393 10/3/2022