|
| 1 | +# BlazorReduxDevToolsExtension |
| 2 | + |
| 3 | +[](https://www.nuget.org/packages/Righthand.BlazorReduxDevToolsExtension) |
| 4 | + |
| 5 | +This is a library that implements the interop between [Blazor](https://github.com/aspnet/Blazor) and [Redux DevTools extension](https://github.com/zalmoxisus/redux-devtools-extension). Which allows you communicating with it and use it's capabilities including time travel debugging. |
| 6 | + |
| 7 | +Core methods are implemented. Options class is not yet implemented. |
| 8 | + |
| 9 | +Built against Blazor 0.2.1. |
| 10 | + |
| 11 | +## Sample usage |
| 12 | + |
| 13 | +You find sample usage in BlazorReduxDevToolsExtensionApp application. |
| 14 | + |
| 15 | +```csharp |
| 16 | +@using BlazorReduxDevToolsExtension |
| 17 | +@page "/" |
| 18 | + |
| 19 | +<h1>ReduxDevTools Extension interop</h1> |
| 20 | + |
| 21 | +<div>Present <b>@IsAvailable</b></div> |
| 22 | +<div>Last Message</div> |
| 23 | +<div>@LastMessage</div> |
| 24 | + |
| 25 | +@functions { |
| 26 | + public bool IsAvailable => ReduxDevToolsExtension.IsAvailable(); |
| 27 | + public string LastMessage { get; private set; } = "Nothing yet"; |
| 28 | + |
| 29 | + protected override void OnInit() |
| 30 | + { |
| 31 | + if (IsAvailable) |
| 32 | + { |
| 33 | + ReduxDevToolsExtension.Connect(); |
| 34 | + ReduxDevToolsExtension.Init(new { Tubo = 88 }); |
| 35 | + ReduxDevToolsExtension.MessageReceived += (s, e) => |
| 36 | + { |
| 37 | + LastMessage = e.Message; |
| 38 | + StateHasChanged(); |
| 39 | + }; |
| 40 | + ReduxDevToolsExtension.Subscribe(); |
| 41 | + ReduxDevToolsExtension.Send(new { type = "AnAction" }, new { Tubo = 109 }); |
| 42 | + ReduxDevToolsExtension.Send(new { type = "Another" }, new { Tubo = 504 }); |
| 43 | + // uncomment it but put a bit of delay in between, otherwise it unsubscribes too early |
| 44 | + //ReduxDevToolsExtension.UnSubscribe(); |
| 45 | + //ReduxDevToolsExtension.Disconnect(); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
0 commit comments