Dagger 2 instance sharing with scopes or named qualifiersWhat determines the lifecycle of a component (object graph) in Dagger 2?Dagger 2 Custom Scope for each Fragment (or Activity etc…)Dagger 2 scope and subcomponentsDagger 2 Singleton vs Real SingletonDagger 2: Provide same instance between multiple Component with same Scope on different library modulesGetting a subcomponent instance into an activityDagger and mvp - should presenter use dagger for injectionHow to create custom scope and share same instances using Dagger AndroidParametrized Qualifiers in Dagger2Better Dagger encapsulation

Journal published a paper, ignoring my objections as a referee

What does it mean to move a single flight control to its full deflection?

Notice period 60 days but I need to join in 45 days

How do I portray irrational anger in first person?

How can I reply to coworkers who accuse me of automating people out of work?

Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?

Where should I draw the line on follow up questions from previous employer

Create a list of snaking numbers under 50,000

Can a network vulnerability be exploited locally?

Why is there no Disney logo in MCU movies?

Why did the population of Bhutan drop by 70% between 2007 and 2008?

Coupling two 15 Amp circuit breaker for 20 Amp

Does throwing a non-weapon item take an action?

Cutting numbers into a specific decimals

Line Feed in monospace font - Macro

Is belaying with a hip belay unsafe?

Is this position a forced win for Black after move 14?

What is Soda Fountain Etiquette?

How do Barton (Hawkeye/Ronin) and Romanov (Black Widow) end up on the Benatar on Morag in 2014?

Get contents before a colon

Pen test results for web application include a file from a forbidden directory that is not even used or referenced

What is the difference between ?int $number and int $number = null?

Are spot colors limited and why CMYK mix is not treated same as spot color mix?

Which polygons can be turned inside out by a smooth deformation?



Dagger 2 instance sharing with scopes or named qualifiers


What determines the lifecycle of a component (object graph) in Dagger 2?Dagger 2 Custom Scope for each Fragment (or Activity etc…)Dagger 2 scope and subcomponentsDagger 2 Singleton vs Real SingletonDagger 2: Provide same instance between multiple Component with same Scope on different library modulesGetting a subcomponent instance into an activityDagger and mvp - should presenter use dagger for injectionHow to create custom scope and share same instances using Dagger AndroidParametrized Qualifiers in Dagger2Better Dagger encapsulation






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Im in the process of setting up my object graph and ran into the following situation. I have provided a simplified tree of classes here as an example. It



  • Recipe Book

    • Apple Pie

      • Ingredients

        • Apple

        • Crust


      • Instructions

        • Crust

        • Apple



    • Apple Jam

      • Ingredients

        • Apple

        • Jar


      • Instructions

        • Jar




The problem I am having is figuring out the best way to structure this in dagger. Essentially, within each Ingredients class, I need the instances of each ingredient to be the same. However, I don't want the Apple instance to be shared between each recipe.



I have tried named qualifiers, but that ends up getting really ugly, really fast. It seems clunky to have to create a provides method for each Apple to give it a name.



Additionally, I have tried a solution where I have created a SubComponent that would have a method to get the Apple. Then I would create a scoped @provides method for that component in the SubComponent meant to make my Ingredients.



My question is, what is typically the best approach for this task?










share|improve this question






























    0















    Im in the process of setting up my object graph and ran into the following situation. I have provided a simplified tree of classes here as an example. It



    • Recipe Book

      • Apple Pie

        • Ingredients

          • Apple

          • Crust


        • Instructions

          • Crust

          • Apple



      • Apple Jam

        • Ingredients

          • Apple

          • Jar


        • Instructions

          • Jar




    The problem I am having is figuring out the best way to structure this in dagger. Essentially, within each Ingredients class, I need the instances of each ingredient to be the same. However, I don't want the Apple instance to be shared between each recipe.



    I have tried named qualifiers, but that ends up getting really ugly, really fast. It seems clunky to have to create a provides method for each Apple to give it a name.



    Additionally, I have tried a solution where I have created a SubComponent that would have a method to get the Apple. Then I would create a scoped @provides method for that component in the SubComponent meant to make my Ingredients.



    My question is, what is typically the best approach for this task?










    share|improve this question


























      0












      0








      0








      Im in the process of setting up my object graph and ran into the following situation. I have provided a simplified tree of classes here as an example. It



      • Recipe Book

        • Apple Pie

          • Ingredients

            • Apple

            • Crust


          • Instructions

            • Crust

            • Apple



        • Apple Jam

          • Ingredients

            • Apple

            • Jar


          • Instructions

            • Jar




      The problem I am having is figuring out the best way to structure this in dagger. Essentially, within each Ingredients class, I need the instances of each ingredient to be the same. However, I don't want the Apple instance to be shared between each recipe.



      I have tried named qualifiers, but that ends up getting really ugly, really fast. It seems clunky to have to create a provides method for each Apple to give it a name.



      Additionally, I have tried a solution where I have created a SubComponent that would have a method to get the Apple. Then I would create a scoped @provides method for that component in the SubComponent meant to make my Ingredients.



      My question is, what is typically the best approach for this task?










      share|improve this question














      Im in the process of setting up my object graph and ran into the following situation. I have provided a simplified tree of classes here as an example. It



      • Recipe Book

        • Apple Pie

          • Ingredients

            • Apple

            • Crust


          • Instructions

            • Crust

            • Apple



        • Apple Jam

          • Ingredients

            • Apple

            • Jar


          • Instructions

            • Jar




      The problem I am having is figuring out the best way to structure this in dagger. Essentially, within each Ingredients class, I need the instances of each ingredient to be the same. However, I don't want the Apple instance to be shared between each recipe.



      I have tried named qualifiers, but that ends up getting really ugly, really fast. It seems clunky to have to create a provides method for each Apple to give it a name.



      Additionally, I have tried a solution where I have created a SubComponent that would have a method to get the Apple. Then I would create a scoped @provides method for that component in the SubComponent meant to make my Ingredients.



      My question is, what is typically the best approach for this task?







      dagger-2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 21:32









      Justin BreitfellerJustin Breitfeller

      12.1k4 gold badges34 silver badges47 bronze badges




      12.1k4 gold badges34 silver badges47 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386774%2fdagger-2-instance-sharing-with-scopes-or-named-qualifiers%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386774%2fdagger-2-instance-sharing-with-scopes-or-named-qualifiers%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해