brianegan / brianegan/redux_dev_tools

Add debug info to Actions

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
9
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Hi, one thing I've come across often is trying to figure out where an action was dispatched from. Usually, with functions, we have easy action to the stacktrace, but not in this case. I solved this by adding the following code to the [store.dart](https://github.com/brianegan/redux_dev_tools/blob/a3213b5b0dd45845074dd607b87c9fbbff55cc30/lib/src/store.dart#L70-L77) file.

```dart
@override
void dispatch(dynamic action) {
if (action is DevToolsAction) {
_devToolsStore.dispatch(action);
} else {
StackTrace stacktrace = StackTrace.current;
final traceLines = stacktrace.toString().split('\n');
var callingFunction = traceLines[1].replaceAll('#1 ', '');
debugPrint("Calling Function: $callingFunction");
_devToolsStore.dispatch(new DevToolsAction.perform(action));
}
}
```
This prints out the calling function and line number it came from.
This needs a better job done to make it useful, but it's a good start.
It would be nice if all actions could be wrapped in an object that added specific debug information in it's properties and could be automatically added to the toString info

I tried forking and adding it myself, but I got the following error, which I didn't understand.

> The current Dart SDK version is 2.6.0-dev.0.0.flutter-6ff8d2199d.
>
> Because redux_dev_tools depends on test >=0.12.0-beta.3 <1.3.0 which requires SDK version >=1.8.0 <2.0.0-∞, version solving failed.
>
> pub get failed (1)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.