Giter Club home page Giter Club logo

Comments (4)

Sloy avatar Sloy commented on May 26, 2024

Awesome idea!
I would personally prefer a more semantic or granular API, such as

public void someMethod() {
    Dexter.forPermissions(Manifest.permission.CAMERA, Manifest.permission.READ_CONTACTS)
          .doOnGranted(someListener)
          .doOnDenied(errorListener)
          .doWhenRationaleShouldBeShown(someListener)
          .onSameThread()
          .check();
}

It's just my personal and maleable opinion. But the idea of a fluent API is great.

from dexter.

Serchinastico avatar Serchinastico commented on May 26, 2024

I can see why you'd separate the doWhenRationaleShouldBeShown callback but I can't think of any use case where you wouldn't handle at least the two basic responses, doOnGranted and doOnDenied. Anyways, you can always create a composite listener with a generic onDenied listener and specific onGranted implementations, actually, you can do the same with the rationale callback as well.

In this case, I'd rather keep a single interface than splitting it into three for three reasons: it's easier to implement, it's easier to understand (IMHO) and we can move towards simpler interfaces whenever we want keeping it backwards compatible (but not the other way around!).

from dexter.

Sloy avatar Sloy commented on May 26, 2024

Yep you're right, it doesn't make much sense implementing only one of the two callbacks. I was thinking more on lambda support. Two methods with one functional interface can use lambdas, but one method with a two method interface can't.
But of course, at the current state of Android, lambda support should not be a priority for an API design :p

Maybe a middle solution would be a RxJava-like listener supporting both forms, one interface with two methods and two interfaces with one method.

Anyway, just that you have thought about it is good enough for me. The real advantage here is the fluent API \o/

from dexter.

pedrovgs avatar pedrovgs commented on May 26, 2024

@Serchinastico do you have a branch to implement this one? Could be great to publish the 3.0.0 version with my last PR #73 and this one.

from dexter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.