Oboe.js – Demo! – What's great?



Oboe.js – Demo! – What's great?

0 1


oboejs-talk

Oboe.js, better JSON through streams

On Github JuanCaicedo / oboejs-talk

A better AJAX

Loading large data easily

What are we going to learn?

Who am I?

Big JSON is hard

Slow page load?

One big AJAX?

Many small AJAX?

Oboe.js

It's this simple

              
oboe('url')
  .node('pattern', function(data){
    // listener code
  });
              
            

Interact on the fly!

Object Oriented?

              
// new Thing(color, shape)
oboe('/myapp/things')
  .node('things.*', function(thing){
    return new Thing(
      thing.color,
      thing.shape
    );
  })
  .done(function(people){
    people[0].colorAndShape();
  })
              
            

Filtering?

              
var greenThings = [];
var blueThings  = [];

oboe('/myapp/things')
  .node('things.*', function(thing){
    if(thing.color === 'blue'){
      blueThings.push(thing);
    } else {
      greenThings.push(thing);
    }
  })
              
            

Memory?

              
oboe('/myapp/thing')
  .node('{ color shape }', function(thing){
    if(thing.color === 'blue'){
      return this.drop;
    }
  })
  .done(function( finalJson){
    console.log(finalJson);
    // ^ {"things": [ , , greenThing, ]}
  })
              
            

Let's you fail gracefully!

On the server

              
router.get('/data', function(req, res) {
  var readStream = fetchYourData();
  readStream.pipe(res);
});
              
            

Or don't

In the shell

                
$ aws datapipeline list-pipelines | node rerun-pipelines.js
              
            

In a node script

                
oboe(process.stdin)
  .node('pipelines.[]', function(pipeline){
    rerun(pipeline);
  })
                
              

Demo!

Data from

http://make8bitart.com/

What's great?

  • Small footprint
  • Few dependencies

What's bad?

Maybe overkill for small data?

Resources

A better AJAX Loading large data easily