Giter Site home page Giter Site logo

Comments (6)

pocorall avatar pocorall commented on June 2, 2024

I wrote the listener-helper as you pointed out because:

  • It is simple that not supporting multiple listener-helper 😄
  • It saves less line-of-code when using multiple listeners

For example, instead of this:

  basis.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener {
    def onItemSelected(p1: AdapterView[_], p2: View, p3: Int, p4: Long): Unit = { doSomething() }
    def onNothingSelected(p1: AdapterView[_]): Unit = {  }
  })

This saves LOC dramatically:

  basis.onItemSelected(doSomething())

Meanwhile, this can be an improvement as well, but less impressive:

  basis.onItemSelected(doSomething())
  basis.onNothingSelected(doAnother())

As you mentioned, addSomeListener approach can be a solution enabling this. But it costs runtime overhead on memory, CPU, and the size of compiled jar. I did not decided that it is worth doing in spite of these overheads.

I admit that it is not documented (non-) feature. One of the most pressing issue is documentation.

from scaloid.

guersam avatar guersam commented on June 2, 2024

I agree. Then how about a macro shows a warning about using 'unsafe' listener in compile time?

from scaloid.

pocorall avatar pocorall commented on June 2, 2024

Developers might get too much warning. Warning usually indicates bad practice, but this is not the case. I think that proper documentation is better.

from scaloid.

pocorall avatar pocorall commented on June 2, 2024

Assigning the same listener multiple times is obviously a bad practice though. Is the Scala macro can handle this?

from scaloid.

guersam avatar guersam commented on June 2, 2024

It will be hard unless the scope is narrow enough. How about to show compile-time warning by default, and allow disabling it by importing specific value? Might need some time though....

from scaloid.

pocorall avatar pocorall commented on June 2, 2024

If it takes some time, leave it and moving to other urgent issues would be wise. I will stay opened this issue.

from scaloid.

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.