{"action":"created","issue":{"url":"https://api.github.com/repos/android10/Android-CleanArchitecture/issues/121","repository_url":"https://api.github.com/repos/android10/Android-CleanArchitecture","labels_url":"https://api.github.com/repos/android10/Android-CleanArchitecture/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/android10/Android-CleanArchitecture/issues/121/comments","events_url":"https://api.github.com/repos/android10/Android-CleanArchitecture/issues/121/events","html_url":"https://github.com/android10/Android-CleanArchitecture/issues/121","id":139719877,"number":121,"title":"Composing Use Case observables","user":{"login":"kiwiandroiddev","id":5158190,"avatar_url":"https://avatars.githubusercontent.com/u/5158190?v=3","gravatar_id":"","url":"https://api.github.com/users/kiwiandroiddev","html_url":"https://github.com/kiwiandroiddev","followers_url":"https://api.github.com/users/kiwiandroiddev/followers","following_url":"https://api.github.com/users/kiwiandroiddev/following{/other_user}","gists_url":"https://api.github.com/users/kiwiandroiddev/gists{/gist_id}","starred_url":"https://api.github.com/users/kiwiandroiddev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiwiandroiddev/subscriptions","organizations_url":"https://api.github.com/users/kiwiandroiddev/orgs","repos_url":"https://api.github.com/users/kiwiandroiddev/repos","events_url":"https://api.github.com/users/kiwiandroiddev/events{/privacy}","received_events_url":"https://api.github.com/users/kiwiandroiddev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-03-09T22:26:32Z","updated_at":"2016-03-10T12:23:33Z","closed_at":null,"body":"Hi guys, great project, at my company we have based an app on this template and the principles in the accompanying blog post.\r\n\r\nFor some more advanced features in the app, we ran into an issue that is very similar to another one mentioned by @amatkivskiy (https://github.com/android10/Android-CleanArchitecture/issues/63). We would like to be able to compose and combine use cases together to form new use cases.\r\n\r\nAs mentioned, RxJava provides a huge toolbox of operators for composing observables which would be perfect. However, the Use Case interface in this project accepts Subscribers and doesn't expose Observables directly.\r\n\r\nThis makes it awkward to compose and combine use cases with RxJava operators. The approach I went with was first to use Subjects to adapt the subscriber interface into an observable, then to create a new custom observable. This works but isn't great as there's a lot of nesting and boilerplate.\r\n\r\nI was wondering what the reasoning behind the design choice of having Use Cases accept Subscribers rather than returning Observables is? Is it so that Use Cases hide the knowledge of which scheduler is used to subscribe on/observe on? What would be the downsides of having Use Cases return a single Observable?\r\n\r\nI'm still new to using Rx in an Android app architecture, so I'm keen to hear some discussion around this and learn something. Thanks again for contributing this to the community :)"},"comment":{"url":"https://api.github.com/repos/android10/Android-CleanArchitecture/issues/comments/194818053","html_url":"https://github.com/android10/Android-CleanArchitecture/issues/121#issuecomment-194818053","issue_url":"https://api.github.com/repos/android10/Android-CleanArchitecture/issues/121","id":194818053,"user":{"login":"lenguyenthanh","id":437967,"avatar_url":"https://avatars.githubusercontent.com/u/437967?v=3","gravatar_id":"","url":"https://api.github.com/users/lenguyenthanh","html_url":"https://github.com/lenguyenthanh","followers_url":"https://api.github.com/users/lenguyenthanh/followers","following_url":"https://api.github.com/users/lenguyenthanh/following{/other_user}","gists_url":"https://api.github.com/users/lenguyenthanh/gists{/gist_id}","starred_url":"https://api.github.com/users/lenguyenthanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lenguyenthanh/subscriptions","organizations_url":"https://api.github.com/users/lenguyenthanh/orgs","repos_url":"https://api.github.com/users/lenguyenthanh/repos","events_url":"https://api.github.com/users/lenguyenthanh/events{/privacy}","received_events_url":"https://api.github.com/users/lenguyenthanh/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T12:23:33Z","updated_at":"2016-03-10T12:23:33Z","body":"@Trikke thanks for your solutions. I prefer 2nd option too, it's more flexible. I'm thinking about adding transformer object to Use Case objects but it doesn't look good. Could you please give me an example of how you implement it? "}}