saga_monitor

Last updated:

0 purchases

saga_monitor Image
saga_monitor Images
Add to Cart

Description:

saga monitor

Saga Monitor for Redux Saga Middleware Dart and Flutter #
Saga Monitor monitors running sagas and effects to track middleware for redux_saga
Package and installation details can be found at pub.dev.
Usage Example #
Modify vanilla_counter according to below to test monitor.
Output can be printed to console.
index.dart
...
var monitor = SimpleSagaMonitor(
onLog: consoleMonitorLogger);

var sagaMiddleware = createSagaMiddleware(Options(sagaMonitor: monitor));
...
copied to clipboard
Sample output:
.✓Root, duration:11ms, result:(Task{Running:true, Cancelled:false, Aborted:false, Result:null, Error:null})
. └─ ✓Fork, duration:4ms, result:(Task{Running:true, Cancelled:false, Aborted:false, Result:null, Error:null})
. ├─ ✓Take, duration:7553ms, result:(Instance of 'IncrementAsyncAction')
. ├─ ✓Fork, duration:5ms, result:(Task{Running:true, Cancelled:false, Aborted:false, Result:null, Error:null})
. │ ├─ ✓Delay, duration:1004ms, result:(true)
. │ └─ ✓Put, duration:2ms, result:(Instance of 'IncrementAction')
. └─ ⌛Take
copied to clipboard
Check vanilla_counter example monitor-console branch for completed code.
To handle where to log implement [onLog] event.
Following example demonstrates how to get lines and
output them to a div element on an html page.
index.dart
...
var monitor = SimpleSagaMonitor(
onLog: (SimpleSagaMonitor monitor) {
var lines = monitor.getLines();
String s = '';
lines.forEach((element) {
s += element + '</br>';
});
querySelector('#monitor').innerHtml = s;
});

var sagaMiddleware = createSagaMiddleware(Options(sagaMonitor: monitor));
...
copied to clipboard
index.html
...
<p>
Clicked: <span id="value">0</span> times
<button id="increment">+</button>
<button id="decrement">-</button>
<button id="incrementIfOdd">Increment if odd</button>
<button id="incrementAsync">Increment async</button>
</br>
</br>
Saga Monitor: <div id="monitor"></div>
</p>
...
copied to clipboard
Check vanilla_counter example monitor-browser branch for completed code.
License #
Copyright (c) 2020 Bilal Uslu.
Licensed under The MIT License (MIT).

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.