Client-side components of the AutoPatch Framework enabling automatic real-time synchronization of objects with server using SignalR and JsonPatch.
$ dotnet add package AutoPatch.ClientReal-time object synchronization between server and client using SignalR and JsonPatch
AutoPatch Framework enables automatic, transparent real-time synchronization of objects between server and client. Once configured, objects are kept in sync automatically without additional code - just subscribe and watch your objects update in real-time.
Live Dashboards • Real-time Tracking • Status Monitoring • Live Feeds • IoT Applications • Multi-tenant Systems
dotnet add package AutoPatch.Server # Server
dotnet add package AutoPatch.Client # Client
// Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddAutoPatch(cfg => cfg.DefaultThrottleInterval = TimeSpan.FromMilliseconds(500))
.AddTrackedCollection<Order>()
.AddSignalR();
var app = builder.Build();
app.UseAutoPatch();
app.Run();
// Use tracked collections
public class OrderService
{
private readonly ObservableCollection<Order> _orders;
public OrderService(ITrackedCollectionManager manager)
{
_orders = manager.GetOrCreateCollection<Order>();
}
public void ProcessOrder(Order order)
{
_orders.Add(order); // → Auto-sync to clients
order.Status = "Processing"; // → Auto-sync property changes
}
}
// App setup
services.AddAutoPatch(cfg => cfg.Endpoint = "http://localhost:5249")
.AddTrackedCollection<Order>();
// Usage
public class OrderViewModel
{
public ObservableCollection<Order> Orders { get; private set; } = [];
public async Task InitializeAsync()
{
await _client.SubscribeToTypeAsync<Order>();
Orders = _client.GetTrackedCollection<Order>(); // Auto-updating collection
}
}
// Server: Collection per tenant
var tenantOrders = manager.GetOrCreateCollection<Order>($"tenant_{tenantId}");
// Client: Subscribe with auth
await client.SubscribeToTypeAsync<Order>("tenant_123", "auth_token");
var orders = client.GetTrackedCollection<Order>("tenant_123");
// Validator
public class OrderValidator : ICollectionSubscriptionValidator<Order>
{
public bool ValidateSubscription(string? auth, string key) => auth == "valid_token";
}
builder.Services.AddTrackedCollection<Order, OrderValidator>();
builder.Services.AddTrackedCollection<Order>(cfg =>
{
cfg.ThrottleInterval = TimeSpan.FromMilliseconds(100); // Update frequency
cfg.ExcludedProperties = ["InternalData"]; // Skip properties
cfg.ClientChangePolicy = ClientChangePolicy.Reject; // Read-only
});
Server: ObservableCollection<T> changes → JsonPatch → SignalR broadcast
Client: Receive patches → Apply to local ObservableCollection<T> → UI updates
Got questions? We're here to help!
🐛 Report Issues - Found a bug or have a feature request?
💬 Join Discussions - Ask questions, share ideas, or showcase your projects
📧 Direct Contact - Need enterprise support or consulting?
⭐ Star the Project - Show your support and stay updated!
Made with ❤️ for real-time applications