How do their APIs compare?
How do their APIs compare?
About karumi/dexter · 2 messages · last activity 9/7/2026
Good comparison question since these two libraries operate at completely different layers, but I can contrast what's visible in the data.
karumi/dexter — Android runtime-permissions API
Dexter exposes a small, fluent builder-style API oriented around a single concern: requesting Android runtime permissions.
- Entry point:
Dexter.withContext(activity)chained with.withPermission(permission)(or presumably a multi-permission variant),.withListener(listener), and.check()to trigger the actual request, as shown in the README usage example [README.md:L1-L20 excerpt / usage section]. - Callback-based results: Rather than returning a value synchronously (impossible given Android's async permission dialog), Dexter uses listener interfaces:
PermissionListenerfor single permissions, withonPermissionGranted(PermissionGrantedResponse),onPermissionDenied(PermissionDeniedResponse), andonPermissionRationaleShouldBeShown(PermissionRequest, PermissionToken)[README.md:L174-L186].MultiplePermissionsListenerfor batches, backed byMultiplePermissionsReport[dexter/src/main/java/com/karumi/dexter/listener/multi/BaseMultiplePermissionsListener.java:L1-L27].
- Convenience base classes:
BasePermissionListener[dexter/src/main/java/com/karumi/dexter/listener/single/BasePermissionListener.java:L1-L27] andBaseMultiplePermissionsListenerlet consumers override only the callbacks they care about, rather than implementing every interface method. - **Control-flow token:[REDACTED]
PermissionToken.continuePermissionRequest()is a distinctive API idiom — because Android pauses the request pipeline while a rationale is being shown, Dexter forces the caller to explicitly resume the flow via this token, blocking further Dexter calls until it's invoked [README.md:L174-L186].
Overall, Dexter's API surface is narrow, synchronous-looking (fluent chain) but async in effect, and entirely UI/permission-domain specific.
netflix/hystrix — resilience/circuit-breaker API
Hystrix's API is broader and infrastructure-oriented, aimed at wrapping arbitrary remote calls with fault tolerance. From the retrieved data, the surface includes:
- Command/closure abstractions:
ClosureCommand,ClosureFactory/AsyncClosureFactory[hystrix-contrib/hystrix-javanica/.../AsyncClosureFactory.java:L1-L23], andClosure(wrapping aMethod+ instance) [.../closure/Closure.java:L1-L23] — these back the Javanica annotation-driven module, letting methods be turned into Hystrix commands via reflection rather than manual subclassing. - Caching support:
HystrixGeneratedCacheKey/DefaultHystrixGeneratedCacheKeyfor request caching keys [.../cache/DefaultHystrixGeneratedCacheKey.java:L1-L24], plus a dedicated exception typeHystrixCacheKeyGenerationExceptionfor cache-key generation failures [.../exception/HystrixCacheKeyGenerationException.java:L1-L22]. - Metrics-as-streams architecture: Per the 1.5.0 changelog, Hystrix moved from aggregate structures (
HystrixRollingNumber,HystrixRollingPercentile) toward stream-based primitives likeHystrixCommandCompletionStream, letting consumers aggregate metrics however they want, including off-box [CHANGELOG.md:L207-L224]. - Request-context lifecycle API:
HystrixRequestContextwas changed to implementCloseable[CHANGELOG.md:L200-L206], aligning it with Java's try-with-resources idiom.
Contrast
| Aspect | Dexter | Hystrix |
|---|---|---|
| Domain | Android permissions UX | Distributed-system fault tolerance |
| Core interaction | Listener callbacks + resumable token | Command objects, closures, streams |
| Async model | Callback-driven, paused via PermissionToken | Async via AsyncClosureFactory, Rx-backed metrics streams |
| Extension mechanism | Base listener classes to override select |
Want to ask your own question?
Open chat for karumi/dexterPublic Q&A. Generated by RepoPilot from the actual source of karumi/dexter. AI answers can be incomplete or stale — verify before relying on them.