{"action":"opened","issue":{"url":"https://api.github.com/repos/reactor/reactor-core/issues/1176","repository_url":"https://api.github.com/repos/reactor/reactor-core","labels_url":"https://api.github.com/repos/reactor/reactor-core/issues/1176/labels{/name}","comments_url":"https://api.github.com/repos/reactor/reactor-core/issues/1176/comments","events_url":"https://api.github.com/repos/reactor/reactor-core/issues/1176/events","html_url":"https://github.com/reactor/reactor-core/issues/1176","id":318279242,"number":1176,"title":"Provide Context merge callback and default multi values impl","user":{"login":"smaldini","id":76718,"avatar_url":"https://avatars2.githubusercontent.com/u/76718?v=4","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},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-27T05:09:01Z","updated_at":"2018-04-27T05:09:01Z","closed_at":null,"author_association":"OWNER","body":"In order to support Context in fan out scenarios such as processors, one solution is to let the user define in the context how to react to merge.\r\n\r\nFor instance let's take a publish() operator with 3 subscribers defining a Context : \r\n\r\n```java\r\nFlux<?> f = \r\n  Flux.create(sink -> {\r\n   Context c = sink.currentContext();\r\n   List<UserInfo> users = c.get(\"all\");\r\n   \r\n   //dostuff\r\n})\r\n  .publish()\r\n  .refCount(3))\r\n  .subscriberContext(ctx ->\r\n      ctx.onMergeWith(\r\n             () -> Context.of(\"all\", new ArrayList<UserInfo>()),\r\n             (ctx1, ctx2) -> Context.of(\"all\", ((List<UserInfo>)ctx1.get(\"all\")).add(ctx2.get(UserInfo.class)));\r\n\r\nf.subscriberContext(Context.of(UserInfo.class, userInfo1).subscribe();\r\nf.subscriberContext(Context.of(UserInfo.class, userInfo2).subscribe();\r\nf.subscriberContext(Context.of(UserInfo.class, userInfo3).subscribe();\r\n```"}}
{"actor":{"display_login":"smaldini"}}