{"action":"created","issue":{"url":"https://api.github.com/repos/gkovac42/mvp-demo/issues/8","repository_url":"https://api.github.com/repos/gkovac42/mvp-demo","labels_url":"https://api.github.com/repos/gkovac42/mvp-demo/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/gkovac42/mvp-demo/issues/8/comments","events_url":"https://api.github.com/repos/gkovac42/mvp-demo/issues/8/events","html_url":"https://github.com/gkovac42/mvp-demo/issues/8","id":279900546,"number":8,"title":"Refactorirati Data metodu","user":{"login":"wideking","id":9109242,"avatar_url":"https://avatars0.githubusercontent.com/u/9109242?v=4","gravatar_id":"","url":"https://api.github.com/users/wideking","html_url":"https://github.com/wideking","followers_url":"https://api.github.com/users/wideking/followers","following_url":"https://api.github.com/users/wideking/following{/other_user}","gists_url":"https://api.github.com/users/wideking/gists{/gist_id}","starred_url":"https://api.github.com/users/wideking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wideking/subscriptions","organizations_url":"https://api.github.com/users/wideking/orgs","repos_url":"https://api.github.com/users/wideking/repos","events_url":"https://api.github.com/users/wideking/events{/privacy}","received_events_url":"https://api.github.com/users/wideking/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-06T20:46:18Z","updated_at":"2017-12-07T18:00:39Z","closed_at":null,"author_association":"NONE","body":"https://github.com/gkovac42/mvp-demo/blob/e24924981b2649e901583d4e36e7867709eaf402/app/src/main/java/com/example/goran/mvpdemo/data/DataInteractor.java#L34\r\n\r\nIdeja iza napisanog ti je u redu ali ima mjesta napretku. Ideja iza rx-a je da kod bude modularan i jednostavniji. Trenutno imaš redudantnom stvari. Za svaki izvor podataka radiš njegov subscriber ( disposable) bez obzira sto se zapravo izvrši. \r\n\r\nBolji način je napraviti observable od izvora - observable uvijek trebaš jer je zanimaju ti podaci pa se zelis moći pretplatiti na njih. Samu pretplatu trebaš raditi kada si siguran sto zelis pratitit, a tvoja logika treba biti takva da bez obzira o kojem izvoru se radi da se prezenter obavijesti. Ovo je najlakše postići sa time da subscribe radiš u metodi za dohvaćanje getData tekkada napraviš svoje observable tu odlučiš koji treba koristiti. Ovo će ti rezultirati micanjem duple logike - subscribe ces raditi na jednom mjestu.\r\nZa dodatne operacije nad observerom koristi flatmap operator, zelis da sto vise teškog posla obaviš na subscribe threadu, a ne kada se vratiš na Observer thread. Vodi se mišlju da se u subscriberu trebaš samo pobrinuti da podaci dođu do onog tko ih treba, dakle sto jednostavnije za mob i tebe.\r\n\r\nVezano uz disposeanje disposablea. Trenutno disposas samo zadnji disposable kojeg zapamtiš. Ovi prethodni ti ostaju u memoriju i mogu dovesti do Memory leaka ( Listener je Memory leak u pitanju jer se poziva iz inter klase - ovo možeš zaključiti po tome sto koristiš lambdu / new keyword pa se unutar te klase referiraš na listener cike stvaraš vezu na njega). . Riješene za ovu muku je koristit compsite disposable objekt koji se ponaša kao velika lista za disposable-E. Svaki puta kada radiš disposable pozoveš nad svojom instancama compositeDisposablea.add() i dodaš disposable. Kada je vrijeme da ih disposas samo pozoveš compositeDisposable.dispose() i tvoje muke su gotove.\r\n\r\nJavi ako imaš nedoumica ili pitanja.\r\n\r\nNisam ostale klase gledao ali vjerujem da ces nakon ovoga znati i na drugim mjestima sto ti je činiti :)\r\n"},"comment":{"url":"https://api.github.com/repos/gkovac42/mvp-demo/issues/comments/350046568","html_url":"https://github.com/gkovac42/mvp-demo/issues/8#issuecomment-350046568","issue_url":"https://api.github.com/repos/gkovac42/mvp-demo/issues/8","id":350046568,"user":{"login":"gkovac42","id":23480045,"avatar_url":"https://avatars2.githubusercontent.com/u/23480045?v=4","gravatar_id":"","url":"https://api.github.com/users/gkovac42","html_url":"https://github.com/gkovac42","followers_url":"https://api.github.com/users/gkovac42/followers","following_url":"https://api.github.com/users/gkovac42/following{/other_user}","gists_url":"https://api.github.com/users/gkovac42/gists{/gist_id}","starred_url":"https://api.github.com/users/gkovac42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkovac42/subscriptions","organizations_url":"https://api.github.com/users/gkovac42/orgs","repos_url":"https://api.github.com/users/gkovac42/repos","events_url":"https://api.github.com/users/gkovac42/events{/privacy}","received_events_url":"https://api.github.com/users/gkovac42/received_events","type":"User","site_admin":false},"created_at":"2017-12-07T18:00:39Z","updated_at":"2017-12-07T18:00:39Z","author_association":"OWNER","body":"Jesam."}}
{"actor":{"display_login":"gkovac42"}}