RxJava Observable join() what is a good use case - rx-java2

im searching for a good example easy to understand on what the join command really does.
it seems its similar to other combined functions like zip or combineLatest perhaps but it mentions having a window of time that it can join... can anyone give a real world example of how to use it ?
i tried so far something like this:
Observable.just(1,2,3).join(Observable.just(4,5,6,7))
but this does not compile.its asking for a leftEnd and a rightEnd functions. but i'm confused what i need to do here and the documentation is a bit confusing.

Related

What's the difference between all the ViewportAdapter Classes in Monogame.Extended?

I'm trying to figure out when to use ViewportAdapter, BoxingViewportAdapter, WindowViewportAdapter, ScalingViewportAdapter and DefaultViewportAdapter in Monogame.Extended. I've played around with them a bit, and I think i have a pretty good understanding of what ScalingViewportAdapter does, but not the rest.
How should I use them? The docs at https://www.monogameextended.net/ does not have a detailed explanation of the classes.

Why does it appear that json4s JObject uses a List(Tuple2) under the hood

This is really bad if it is what I think it is. I'm still learning Scala so I could be missing something HUGE but if I need constant time access to a specific element in a JObject, wouldn't storing the elements as a List(Tuple2) be REALLY REALLY REALLY bad for runtime?
I'm working on an application which uses Spark... and it looks like Spark is using json4s. I could imagine there's a good reasoning behind this, or maybe I don't know enough about Scala yet to understand why this doesn't matter.
Any thoughts?

Chaining queries with pymongo

So, I'm currently trying to make an extensible wrapper for pymongo and I found myself wishing that it was possible to query a cursor. This is mostly for making the api as clean as possible. Basically what I was imagining was something along these lines:
def get_all_x_type(collection):
return collection.find({"type":"x"})
def get_all_y_kind(collection):
return collection.find({"kind": "y"})
def get_all_x_and_y(collection):
return get_all_x(get_all_y(collection))
Implementation details are actually nicer than that, but that's the general functionality I'm looking for. I know it's possible to just extend the find query, but I would like to be able to deal with cursors passed to me from other people. Is there any way to do something like this? I could checks on the cursor as I iterate through it, but that seems pretty gross and I was looking for something a bit cleaner.
Alternately is this a silly idea for some reason? I'm not a mongo expert by any means, but this functionality seemed useful to me, but it might just be my naivete.

Key-Value-Observation -- Looking for a more elegant solution to respond to value changes

I've run into a frustrating feature of KVO: all notifications are funneled through a single method (observeValueForKeyPath:....), requiring a bunch of IF statements if the object is observing numerous properties.
The ideal solution would be to pass a method as an argument to the method that establishes the observing in the first place, but it seems this isn't possible. Does a solution exist to this problem? I initially considered using the keyPath argument (addObserver:forKeyPath:options:context:) to call a method via NSSelectorFromString, but then I came across the post KVO Dispatcher pattern with Method as context and the article it linked to which offers a different solution in order to pass arguments along as well (although I haven't gotten that working yet).
I know a lot of people have come up against this issue. Has a standard way of handling it emerged?
OP asks:
Has a standard way of handling it emerged?
No, not really. There are a lot of different approaches out there. Here are some:
https://github.com/sleroux/KVO-Blocks
http://pandamonia.github.io/BlocksKit
http://www.mikeash.com/pyblog/friday-qa-2012-03-02-key-value-observing-done-right-take-2.html
https://github.com/ReactiveCocoa/ReactiveCocoa
http://blog.andymatuschak.org/post/156229939/kvo-blocks-block-callbacks-for-cocoa-observers
Seriously, there are a ton of these... Google "KVO blocks"
I can't say that any of the options I've seen seem prevalent enough to earn the title "standard way". I suspect most folks who feel motivated to conquer this issue just pick one and go with it, or write their own -- it's not as if adapting KVO to use block based callbacks is rocket science. The Method-based approach you link to doesn't seem like a step forward for simplicity. I get that you're trying to take the uncertainty of the string-based-key-path <-> method conversion out of the equation, but that kind of falls down because not all observable keys/keyPaths are methods. (If nothing else, you can observe arbitrary keys on NSMutableDictionaries and get notifications.)
It sure would be nice if Apple would release a new blocks-based KVO API, but I'm not holding my breath. But in the meantime, like I said, just pick one you like and use it or write your own and use that.

Autogenerated keys in Pilog

What's the best way to go about autogenerated keys for Pilog? i've
been digging around a bit and can't find anything related.
Hints and pointers would be most appreciated. Thank you.
You get the same behavior as auto increment in for instance MySQL with this
one: http://software-lab.de/doc/refG.html#genKey
I use it a lot in the VizReader code.
I'm not so sure I would've used it much though if I had know about the (id)
function from the start: http://software-lab.de/doc/refI.html#id
In my case it's all about displaying a nice id that is easy to relate for
humans and JavaScript in my non-traditional gui and as you can see both
approaches accomplish that but that latter is imo more elegant.
/Henrik Sarvell
(Copied verbatim form Henrik Sarvells' answer.)