{"action":"created","issue":{"url":"https://api.github.com/repos/reactor/reactor-core/issues/278","repository_url":"https://api.github.com/repos/reactor/reactor-core","labels_url":"https://api.github.com/repos/reactor/reactor-core/issues/278/labels{/name}","comments_url":"https://api.github.com/repos/reactor/reactor-core/issues/278/comments","events_url":"https://api.github.com/repos/reactor/reactor-core/issues/278/events","html_url":"https://github.com/reactor/reactor-core/issues/278","id":192231112,"number":278,"title":"Use doOnNext multiple times","user":{"login":"Yevhenii-Melnyk","id":3802287,"avatar_url":"https://avatars.githubusercontent.com/u/3802287?v=3","gravatar_id":"","url":"https://api.github.com/users/Yevhenii-Melnyk","html_url":"https://github.com/Yevhenii-Melnyk","followers_url":"https://api.github.com/users/Yevhenii-Melnyk/followers","following_url":"https://api.github.com/users/Yevhenii-Melnyk/following{/other_user}","gists_url":"https://api.github.com/users/Yevhenii-Melnyk/gists{/gist_id}","starred_url":"https://api.github.com/users/Yevhenii-Melnyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yevhenii-Melnyk/subscriptions","organizations_url":"https://api.github.com/users/Yevhenii-Melnyk/orgs","repos_url":"https://api.github.com/users/Yevhenii-Melnyk/repos","events_url":"https://api.github.com/users/Yevhenii-Melnyk/events{/privacy}","received_events_url":"https://api.github.com/users/Yevhenii-Melnyk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-29T09:35:43Z","updated_at":"2016-11-29T09:48:34Z","closed_at":null,"body":"I was trying to change a little reactor samples from [here](https://github.com/reactor/reactor-samples/blob/master/src/main/java/org/projectreactor/samples/FluxSamples.java) and I'm a little confused with the behaviour I get.\r\n\r\nSo first the code looks like this:\r\n\r\n\tEmitterProcessor<String> stream = EmitterProcessor.<String>create().connect();\r\n\tFlux<String> flux = stream\r\n\t\t\t.doOnNext(s -> System.out.println(\"1  \" + s))\r\n\t\t\t.doOnNext(s -> System.out.println(\"2  \" + s));\r\n\tflux.subscribe();\r\n\tstream.onNext(\"Hello\");\r\n\r\nThis code prints two lines as expected:\r\n\r\n\t1 Hello\r\n\t2 Hello\r\n\r\nBut if I add an intermediate variable pretending I get it from some method or for readability, the code starts to behave differently.\r\n\r\n    EmitterProcessor<String> stream = EmitterProcessor.<String>create().connect();\r\n    Flux<String> flux = stream\r\n            .doOnNext(s -> System.out.println(\"1 \" + s));\r\n    flux.doOnNext(s -> System.out.println(\"2 \" + s));\r\n    flux.subscribe();\r\n    stream.onNext(\"Hello\");\r\n\r\nThe code above gives only one line of output, that is:\r\n\r\n\t1 Hello\r\n\r\nHow is this possible?"},"comment":{"url":"https://api.github.com/repos/reactor/reactor-core/issues/comments/263524394","html_url":"https://github.com/reactor/reactor-core/issues/278#issuecomment-263524394","issue_url":"https://api.github.com/repos/reactor/reactor-core/issues/278","id":263524394,"user":{"login":"smaldini","id":76718,"avatar_url":"https://avatars.githubusercontent.com/u/76718?v=3","gravatar_id":"","url":"https://api.github.com/users/smaldini","html_url":"https://github.com/smaldini","followers_url":"https://api.github.com/users/smaldini/followers","following_url":"https://api.github.com/users/smaldini/following{/other_user}","gists_url":"https://api.github.com/users/smaldini/gists{/gist_id}","starred_url":"https://api.github.com/users/smaldini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smaldini/subscriptions","organizations_url":"https://api.github.com/users/smaldini/orgs","repos_url":"https://api.github.com/users/smaldini/repos","events_url":"https://api.github.com/users/smaldini/events{/privacy}","received_events_url":"https://api.github.com/users/smaldini/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T09:48:34Z","updated_at":"2016-11-29T09:48:34Z","body":"The core principle sticks to functional programming and reactive extensions basics, you build a chain that you have to subscribe interest in sequence. Effectively a subscription state materialize when at the very end/right you call subscribe(?options) so in your case you have to \r\n\"doOnNext(s -> xxxx).subscribe(xx)\", otherwise its like you have prepared 2 flows to be subscribed and you actually subscribed without any of these preparations."}}
{"actor":{"display_login":"smaldini"}}