Live data from Hacker News

Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

github.com

21–30 of 74 posts

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#21

This probably won't work if you have gzip on, right?

I'll have to test to be sure you still get streaming. It depends how the browsers handle xhr2 events with regard to gzip'd http. I /think/ it'll be fine but I need to check to be sure. Eg, with gzip on you still get progressive html rendering.

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#22
post #9

This seems like it could be used to create a protocol similar to XMPP - which I always enjoyed from the perspective of elegance. I might have a pet project this weekend, thanks for sharing.

There's a cool thing you might try where you can download the historic messages, then continue to stream live ones over the same http. If you don't care about old browsers (anything without xhr2 progress events) should work fine to download and stream on same connection.

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#25
post #18
post #13

Earlier quoted context omitted.

You might need "nonFoods" sometime later but not right now at the start of the app. But instead of making 2 http requests you just make one, but use the thing you actually need as soon as it's available. If you scroll the README file to the bottom you'll find some good use cases that explain it better than I just did :)

Yeah! There are more understandable examples further down. suggestion @joombar: since the first example is the first thing people see and it doesn't actually reflect the core usecase, perhaps add a note explaining that the example is contrived for simplicity's sake ~or~ make the primary example represent the core usecase more closely. Cool project!

Hmmmm, yeah. Use cases doesn't take up much space, I'll put that before examples because it explains better what it is for.

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#26
post #14
post #10

This looks really cool! I'm confused about the usecase, however. In your foods/nonfoods example[0], it allows you to request a some JSON with 2 keys, `foods` and `"nonFoods"`, each with an array value, and use only foods, discarding nonFoods. You request this from oboe('/myapp/things.json') My question: why not modify the backend to accept a request like `/myapp/foods.json` and let the backend compose the json you ne…

I suppose the example is a little artificial. It isn't really for using some of the JSON response while ignoring the rest (well, you can use it for that but it isn't the main use). I got the idea for this project working on data vis. Not all of the data was visible and we wanted to display the first bit of data quicker without waiting for all of it to arrive. We could have just sent the visible bit but it was good to…

> well, you can use it for that but it isn't the main use

Actually, you could use it for that, as long as the library actually finishes downloading the file on abort. If you need contents from the file again, you just download it again and as it will already be cached, that operation should be extremely fast.

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#27
This could be big for making dynamic web maps faster. Often we request a large array of geometries to display on a map and can only display them all at once after ajax is done. If we could display each geometry as they are loaded it would be a big improvement to perceived performance. I imagine this is the case for other kinds of data vis as well. Off to test!

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#29

Earlier quoted context omitted.

Awesome! I'll investigate how easily we can stream our JSON out.

Its probably not worth changing it if it is eg in a file already, but if the process to generate it is a slow one it might be.

I agree. If you're doing something slow/asynchronous like aggregating several http resources it is worth it to write out as early as you can but keep server-side the same if you can generate the whole JSON quickly.

Re: Oboe.js: reacting to Ajax/Rest quicker by not waiting for it to finish

#30

This is basically node-trumpet in the browser. Really great stuff! https://github.com/substack/node-trumpet

Hadn't seen that before. Interesting link, thanks.

Very similar except JSON/JSONPath instead of HTML/CSS. Oboe runs fine in Node but I want to make the code a bit more standards-y. Ie, using Node's EventEmitters instead of the little pubsub I made for the browser.

Post reply on HN