add subscriber to Single observed value












1















I would like to know how can I add the subscriber for single as shown below in the code.
when i try to add .subscribe() or .blockingsubscribe() the autocomplete in eclise does not show them



code:



Single<List<List<Person>>> singles = Single.just(Main.getPersons());
singles
.observeOn(Schedulers.io())
.map(x->System.out.println(x.size()))









share|improve this question



























    1















    I would like to know how can I add the subscriber for single as shown below in the code.
    when i try to add .subscribe() or .blockingsubscribe() the autocomplete in eclise does not show them



    code:



    Single<List<List<Person>>> singles = Single.just(Main.getPersons());
    singles
    .observeOn(Schedulers.io())
    .map(x->System.out.println(x.size()))









    share|improve this question

























      1












      1








      1








      I would like to know how can I add the subscriber for single as shown below in the code.
      when i try to add .subscribe() or .blockingsubscribe() the autocomplete in eclise does not show them



      code:



      Single<List<List<Person>>> singles = Single.just(Main.getPersons());
      singles
      .observeOn(Schedulers.io())
      .map(x->System.out.println(x.size()))









      share|improve this question














      I would like to know how can I add the subscriber for single as shown below in the code.
      when i try to add .subscribe() or .blockingsubscribe() the autocomplete in eclise does not show them



      code:



      Single<List<List<Person>>> singles = Single.just(Main.getPersons());
      singles
      .observeOn(Schedulers.io())
      .map(x->System.out.println(x.size()))






      java java-8 observable rx-java2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 8:33









      LetsamrItLetsamrIt

      1,23432041




      1,23432041
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Your map function should return something that you want to subscribe on:



          .map(x -> {
          System.out.println(x.size());
          return ???;
          });





          share|improve this answer


























          • thanks but i want to use onsuccess and onError

            – LetsamrIt
            Nov 13 '18 at 9:04











          • you still going to need a subscription

            – taygetos
            Nov 13 '18 at 9:11











          • yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

            – LetsamrIt
            Nov 13 '18 at 9:21











          • Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

            – taygetos
            Nov 13 '18 at 9:27













          • Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

            – akarnokd
            Nov 13 '18 at 9:42



















          1














          You are using the wrong lambda and it throws off your IDE. Try this:



          Single<List<List<Person>>> singles = Single.just(Main.getPersons());
          singles
          .observeOn(Schedulers.io())
          .doOnSuccess(x -> System.out.println(x.size()))
          . // <---------------------------------------- now it should bring up the autocomplete





          share|improve this answer


























          • You're right, he probably wants to use the .doOnNext

            – taygetos
            Nov 13 '18 at 9:37











          • thanks but why i could not use .map directly? it is Single and i should use map operator normally??

            – LetsamrIt
            Nov 13 '18 at 10:14











          • also there is no doOnNext with songle

            – LetsamrIt
            Nov 13 '18 at 10:18











          • Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

            – akarnokd
            Nov 13 '18 at 10:21











          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%2f53276833%2fadd-subscriber-to-single-observed-value%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Your map function should return something that you want to subscribe on:



          .map(x -> {
          System.out.println(x.size());
          return ???;
          });





          share|improve this answer


























          • thanks but i want to use onsuccess and onError

            – LetsamrIt
            Nov 13 '18 at 9:04











          • you still going to need a subscription

            – taygetos
            Nov 13 '18 at 9:11











          • yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

            – LetsamrIt
            Nov 13 '18 at 9:21











          • Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

            – taygetos
            Nov 13 '18 at 9:27













          • Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

            – akarnokd
            Nov 13 '18 at 9:42
















          1














          Your map function should return something that you want to subscribe on:



          .map(x -> {
          System.out.println(x.size());
          return ???;
          });





          share|improve this answer


























          • thanks but i want to use onsuccess and onError

            – LetsamrIt
            Nov 13 '18 at 9:04











          • you still going to need a subscription

            – taygetos
            Nov 13 '18 at 9:11











          • yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

            – LetsamrIt
            Nov 13 '18 at 9:21











          • Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

            – taygetos
            Nov 13 '18 at 9:27













          • Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

            – akarnokd
            Nov 13 '18 at 9:42














          1












          1








          1







          Your map function should return something that you want to subscribe on:



          .map(x -> {
          System.out.println(x.size());
          return ???;
          });





          share|improve this answer















          Your map function should return something that you want to subscribe on:



          .map(x -> {
          System.out.println(x.size());
          return ???;
          });






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 8:57

























          answered Nov 13 '18 at 8:48









          taygetostaygetos

          867716




          867716













          • thanks but i want to use onsuccess and onError

            – LetsamrIt
            Nov 13 '18 at 9:04











          • you still going to need a subscription

            – taygetos
            Nov 13 '18 at 9:11











          • yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

            – LetsamrIt
            Nov 13 '18 at 9:21











          • Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

            – taygetos
            Nov 13 '18 at 9:27













          • Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

            – akarnokd
            Nov 13 '18 at 9:42



















          • thanks but i want to use onsuccess and onError

            – LetsamrIt
            Nov 13 '18 at 9:04











          • you still going to need a subscription

            – taygetos
            Nov 13 '18 at 9:11











          • yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

            – LetsamrIt
            Nov 13 '18 at 9:21











          • Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

            – taygetos
            Nov 13 '18 at 9:27













          • Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

            – akarnokd
            Nov 13 '18 at 9:42

















          thanks but i want to use onsuccess and onError

          – LetsamrIt
          Nov 13 '18 at 9:04





          thanks but i want to use onsuccess and onError

          – LetsamrIt
          Nov 13 '18 at 9:04













          you still going to need a subscription

          – taygetos
          Nov 13 '18 at 9:11





          you still going to need a subscription

          – taygetos
          Nov 13 '18 at 9:11













          yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

          – LetsamrIt
          Nov 13 '18 at 9:21





          yes i know but can show me how to use the subscription?? i cant use it please provide an examlple

          – LetsamrIt
          Nov 13 '18 at 9:21













          Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

          – taygetos
          Nov 13 '18 at 9:27







          Single<List<List<Person>>> singles = Single.just(Main.getPersons()); singles .observeOn(Schedulers.io()) .map(x -> s.size()) .subscribe(x -> System.out.println(x))

          – taygetos
          Nov 13 '18 at 9:27















          Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

          – akarnokd
          Nov 13 '18 at 9:42





          Could be the OP wants to print and return the size like you suggested. It is really hard to guess as the OP keeps asking questions with the very same code example over and over...

          – akarnokd
          Nov 13 '18 at 9:42













          1














          You are using the wrong lambda and it throws off your IDE. Try this:



          Single<List<List<Person>>> singles = Single.just(Main.getPersons());
          singles
          .observeOn(Schedulers.io())
          .doOnSuccess(x -> System.out.println(x.size()))
          . // <---------------------------------------- now it should bring up the autocomplete





          share|improve this answer


























          • You're right, he probably wants to use the .doOnNext

            – taygetos
            Nov 13 '18 at 9:37











          • thanks but why i could not use .map directly? it is Single and i should use map operator normally??

            – LetsamrIt
            Nov 13 '18 at 10:14











          • also there is no doOnNext with songle

            – LetsamrIt
            Nov 13 '18 at 10:18











          • Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

            – akarnokd
            Nov 13 '18 at 10:21
















          1














          You are using the wrong lambda and it throws off your IDE. Try this:



          Single<List<List<Person>>> singles = Single.just(Main.getPersons());
          singles
          .observeOn(Schedulers.io())
          .doOnSuccess(x -> System.out.println(x.size()))
          . // <---------------------------------------- now it should bring up the autocomplete





          share|improve this answer


























          • You're right, he probably wants to use the .doOnNext

            – taygetos
            Nov 13 '18 at 9:37











          • thanks but why i could not use .map directly? it is Single and i should use map operator normally??

            – LetsamrIt
            Nov 13 '18 at 10:14











          • also there is no doOnNext with songle

            – LetsamrIt
            Nov 13 '18 at 10:18











          • Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

            – akarnokd
            Nov 13 '18 at 10:21














          1












          1








          1







          You are using the wrong lambda and it throws off your IDE. Try this:



          Single<List<List<Person>>> singles = Single.just(Main.getPersons());
          singles
          .observeOn(Schedulers.io())
          .doOnSuccess(x -> System.out.println(x.size()))
          . // <---------------------------------------- now it should bring up the autocomplete





          share|improve this answer















          You are using the wrong lambda and it throws off your IDE. Try this:



          Single<List<List<Person>>> singles = Single.just(Main.getPersons());
          singles
          .observeOn(Schedulers.io())
          .doOnSuccess(x -> System.out.println(x.size()))
          . // <---------------------------------------- now it should bring up the autocomplete






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 10:19

























          answered Nov 13 '18 at 9:23









          akarnokdakarnokd

          49k9100148




          49k9100148













          • You're right, he probably wants to use the .doOnNext

            – taygetos
            Nov 13 '18 at 9:37











          • thanks but why i could not use .map directly? it is Single and i should use map operator normally??

            – LetsamrIt
            Nov 13 '18 at 10:14











          • also there is no doOnNext with songle

            – LetsamrIt
            Nov 13 '18 at 10:18











          • Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

            – akarnokd
            Nov 13 '18 at 10:21



















          • You're right, he probably wants to use the .doOnNext

            – taygetos
            Nov 13 '18 at 9:37











          • thanks but why i could not use .map directly? it is Single and i should use map operator normally??

            – LetsamrIt
            Nov 13 '18 at 10:14











          • also there is no doOnNext with songle

            – LetsamrIt
            Nov 13 '18 at 10:18











          • Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

            – akarnokd
            Nov 13 '18 at 10:21

















          You're right, he probably wants to use the .doOnNext

          – taygetos
          Nov 13 '18 at 9:37





          You're right, he probably wants to use the .doOnNext

          – taygetos
          Nov 13 '18 at 9:37













          thanks but why i could not use .map directly? it is Single and i should use map operator normally??

          – LetsamrIt
          Nov 13 '18 at 10:14





          thanks but why i could not use .map directly? it is Single and i should use map operator normally??

          – LetsamrIt
          Nov 13 '18 at 10:14













          also there is no doOnNext with songle

          – LetsamrIt
          Nov 13 '18 at 10:18





          also there is no doOnNext with songle

          – LetsamrIt
          Nov 13 '18 at 10:18













          Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

          – akarnokd
          Nov 13 '18 at 10:21





          Map requires a Function that takes an item and returns an item. A lambda of x -> System.out.println(x.size()) does not return anything as println is a void method. This is a syntax error so the IDE can no longer follow the types and suggest anything via autoComplete.

          – akarnokd
          Nov 13 '18 at 10:21


















          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%2f53276833%2fadd-subscriber-to-single-observed-value%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







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()