On 2/28/18 3:36 PM, Robert M. Münch wrote:
Yes, that's what the docs state. And I can imagin this. Bit this sentence is a bit hard to understand: "If fun is not a string, unaryFun aliases itself away to fun." Whatever this means.

It means that it simply becomes the alias you passed in. It means, there's no extra overhead in calling that unaryFun. But if you pass it something that needs some wrapping, it will do the wrapping.


This question is a little harder to understand. Perhaps you have real code that shows what you are confused about?

Ok, here it is: https://pastebin.com/tKACi488

See lines 81-84 for how I call it. And the problem I have is that doSubscribe returns "something" I'm not sure what I can do with. But if the scope ends, my subscription seems to be deleted and hence is not called when a message is coming in (see line: 118)


Looking through the rx package, it seems that it returns a class instance. That class implements the Disposable interface.

And the question is now, what do I have to do that subscriptions that are done anywhere in the code survive the scope where they have been created?

I'm guessing from this observation that the class instance will unregister the subscription if it's destroyed, and because you aren't keeping a reference to that instance, the GC comes along and destroys it at some point.

What I would recommend is you have to keep a reference to that class somewhere. Start out by just assigning it to a global. If that fixes your problem, I suggest you reach out to the author of rx, or read through the docs to see how you should properly use it, and where you need to keep that subscription (and for what purpose).

If that *doesn't* fix your problem, then I'm not understanding what is happening, and you should definitely contact the rx author. File an issue in the github project.

-Steve

Reply via email to