Coder Social home page Coder Social logo

Comments (3)

JakeWharton avatar JakeWharton commented on June 10, 2024

Nice find. This is a bit of an edge case, but one we indeed thought of when designing @Produce. The reason for this is that while post() is a one-to-many operation we don't want register()-->subscribe() to produce multiple invocations.

Take for example this case:

class A {
  @Produce public CharSequence provideChar() { return "char"; }
  @Produce public String produceString() { return "string"; }
  @Subscribe public void onObject(Object object) {
    System.out.println("GOT: " + object);
  }
}

While very obviously an extreme case, you can see where the problem lies. If there are multiple @Produce-annotated methods which subclass @Subscribe types it becomes ambiguous which to call (or it requires multiple invocations).

This is why we require explicit 1:1 mapping.

from otto.

grodin avatar grodin commented on June 10, 2024

Thanks for the explanation, that makes a lot of sense.

If I wanted to submit a pull request to make this explicit in the Javadoc and website, I should target the 2.0-wip branch, correct?

from otto.

JakeWharton avatar JakeWharton commented on June 10, 2024

PRs should be against master.
On Mar 5, 2014 4:22 AM, "grodin" [email protected] wrote:

Thanks for the explanation, that makes a lot of sense.

If I wanted to submit a pull request to make this explicit in the Javadoc
and website, I should target the 2.0-wip branch, correct?

Reply to this email directly or view it on GitHubhttps://github.com//issues/106#issuecomment-36736893
.

from otto.

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.