-
Notifications
You must be signed in to change notification settings - Fork 28
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
Resource Manager #18
Comments
Hi George Observable<byte[]> bytes = new ResourceManager(
() -> new FileInputStream(file),
is -> is.close())
.checkout(is -> bytesFrom(is)); Just for comparison, I normally use: Observable<byte> bytes =
Observable.using(
Checked.f0(() -> new FileInputStream(file)),
is -> bytesFrom(is),
Checked.a1(is -> is.close())); I can certainly imagine the currying aspect of your offering being useful. Now that we are chatting about it another overload of |
@abersnaze Do you want to make a PR or would you like me to pop it in? |
With the direct comparison it's hard to see but by separating the management from the usage it makes the user code simpler.
I think this API could have a few more options to have resource pooling and fallbacks if resources are not available. I can submit a PR too. |
I am looking for a solution to close / dispose a set of observable resources, i.e., to call the close method on each item but only when all users are over to free the resources. What I mean all users are over is it cannot be passed to any |
Sounds like you need to look at Observable.using (...).share(); On Tue, 20 Sep 2016, 19:52 Suminda Dharmasena [email protected]
|
I am looking for RefCounting of the contained objects. E.g. I have a set of objects which allocate native resources. This is not exact what I am using but help you get a sense of it through my concern is not a file like in this example:
Once you are done with The above use case is if you have one resource from which you are getting a stream of observables not necessarily dealing with a stream of resources. |
I have this bit of code that I've used a couple of times and I figured it could use a good home. Its a class for currying the resource creation and clean of the
rx.Observable#using
function. Would this be a good fit for this project?The text was updated successfully, but these errors were encountered: