项目作者: reduxsaga

项目描述 :
Saga Monitor for Redux Saga
高级语言: Dart
项目地址: git://github.com/reduxsaga/saga_monitor.git
创建时间: 2020-08-22T21:08:19Z
项目社区:https://github.com/reduxsaga/saga_monitor

开源协议:MIT License

下载


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

  1. ...
  2. var monitor = SimpleSagaMonitor(
  3. onLog: consoleMonitorLogger);
  4. var sagaMiddleware = createSagaMiddleware(Options(sagaMonitor: monitor));
  5. ...

Sample output:

  1. .✓Root, duration:11ms, result:(Task{Running:true, Cancelled:false, Aborted:false, Result:null, Error:null})
  2. . └─ Fork, duration:4ms, result:(Task{Running:true, Cancelled:false, Aborted:false, Result:null, Error:null})
  3. . ├─ Take, duration:7553ms, result:(Instance of 'IncrementAsyncAction')
  4. . ├─ Fork, duration:5ms, result:(Task{Running:true, Cancelled:false, Aborted:false, Result:null, Error:null})
  5. . ├─ Delay, duration:1004ms, result:(true)
  6. . └─ Put, duration:2ms, result:(Instance of 'IncrementAction')
  7. . └─ Take

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

  1. ...
  2. var monitor = SimpleSagaMonitor(
  3. onLog: (SimpleSagaMonitor monitor) {
  4. var lines = monitor.getLines();
  5. String s = '';
  6. lines.forEach((element) {
  7. s += element + '</br>';
  8. });
  9. querySelector('#monitor').innerHtml = s;
  10. });
  11. var sagaMiddleware = createSagaMiddleware(Options(sagaMonitor: monitor));
  12. ...

index.html

  1. ...
  2. <p>
  3. Clicked: <span id="value">0</span> times
  4. <button id="increment">+</button>
  5. <button id="decrement">-</button>
  6. <button id="incrementIfOdd">Increment if odd</button>
  7. <button id="incrementAsync">Increment async</button>
  8. </br>
  9. </br>
  10. Saga Monitor: <div id="monitor"></div>
  11. </p>
  12. ...

Check vanilla_counter example monitor-browser branch for completed code.

License

Copyright (c) 2020 Bilal Uslu.

Licensed under The MIT License (MIT).