Skip to content

Commit 99cd831

Browse files
authored
Add usage example to README
1 parent 3c15a9f commit 99cd831

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,47 @@ dependencies {
4949

5050
RxJava 2.1.0+
5151

52+
# Usage
53+
54+
Just enable RxJava2Debug as soon as possible. In Android, for example:
55+
56+
```java
57+
public class MyApplication extends Application {
58+
59+
@Override
60+
public void onCreate() {
61+
super.onCreate();
62+
63+
Fabric.with(this, new Crashlytics());
64+
65+
// Enable RxJava assembly stack collection, to make RxJava crash reports clear and unique
66+
// Make sure this is called AFTER setting up any Crash reporting mechanism as Crashlytics
67+
RxJava2Debug.enableRxJava2AssemblyTracking(new String[]{"com.example.myapp", "com.example.mylibrary"});
68+
}
69+
}
70+
```
71+
72+
This will:
73+
74+
- Enhance stack traces of all RxJava2-related crashes making sure they contain a reference to the method that generated the first event in the Rx pipeline
75+
- Make sure that Stack Traces contain a reference to your code (some class in `com.example.myapp` or `com.example.mylibrary`)
76+
- Make sure that crash reports in Crashlytics are actually different for each pipeline (avoid bundling every RXJava error into one reports)
77+
78+
You will now also be able to obtain an enhanced Stack Trace even when you implement `onError` (really, you should implement it):
79+
80+
```java
81+
responseSubject
82+
.subscribe(
83+
responseObservable -> handleResponse(responseObservable),
84+
throwable -> RxJava2Debug.getEnhancedStackTrace(throwable)
85+
);
86+
```
87+
88+
| Without RxJava2Debug | With RxJava2Debug |
89+
| - | - |
90+
| ![raw stack trace](https://github.com/akaita/RxJava2Debug/blob/master/screenshots/raw_stack_trace.png "Raw Stack Trace") | ![enhanced stack trace](https://github.com/akaita/RxJava2Debug/blob/master/screenshots/enhanced_stack_trace.png "Enhanced Stack Trace") |
91+
| ![raw crash report](https://github.com/akaita/RxJava2Debug/blob/master/screenshots/raw_crash_report.png "Raw Crash Report") | ![enhanced crash report](https://github.com/akaita/RxJava2Debug/blob/master/screenshots/enhanced_crash_report.png "Enhanced Crash Report") |
92+
5293
# API
5394

5495
Start collecting information about RxJava's execution to provide a more meaningful StackTrace in case of crash

0 commit comments

Comments
 (0)