Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result.toObservable() which emits result on subscribe and on further updates. #11

Closed
vtuan10 opened this issue Feb 23, 2016 · 6 comments
Assignees

Comments

@vtuan10
Copy link

vtuan10 commented Feb 23, 2016

As far as i can see, Result has two toObservable-methods:

  • toObservable: Converts the Result to an Observable which, emits an item of result at a time.
  • toSelfObservable: Emits only, when a commit affects the query.

Enhancement:
It would be nice to have an Observable, which emits once on subscribe and emits on further updates (like in StorIO). With this, the first toObservable wouldn't be needed anymore, since we can simulate it with take(1) and flatmap. The second could be simulated by skip(1).

@npurushe
Copy link
Contributor

It looks like from their example in StorIO emits a list of items back each time with the results. So it looks like you want the Result itself emitted back on subscribe and on subsequent changes?

I think toObservable() would still be needed for other cases where you just need a sequence of the elements in the result but this looks like it could also be added. Thanks for the feedback.

@vtuan10
Copy link
Author

vtuan10 commented Feb 23, 2016

Yes, in my usecase I subscribe in the onCreate method of an activity to get my data and create my views according to the data. So I have to get my data once for initialization and then subsribe to it again to get further updates. To have all of this in 1 subscription would be awesome. Maybe I'm just spoiled from StorIO :D

Again thanks for this awesome library :)

@npurushe
Copy link
Contributor

Sure :) Do you think something like an overload of toSelfObservable(boolean emit), that if emit true emits right away would fit your use case?

@vtuan10
Copy link
Author

vtuan10 commented Feb 23, 2016

yes, thats good.

@npurushe npurushe self-assigned this Feb 23, 2016
@npurushe
Copy link
Contributor

Ok sounds simple enough! Will work on this for the next update

@npurushe
Copy link
Contributor

It made sense to make this the default behavior so added in latest snapshot version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants