Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test initial
.gitignore
.travis.yml initial
LICENSE
README.md
index.js
package.json 0.0.1

README.md

query-stream

create autosuggest widgets with a async function.

create a query stream:

var query = require('query-stream')
var qs = query(function (query, cb) {
  //make request to 
  make_query_to_wherever(query, cb)
})

then, write queries to it:

qs.write('samestuth')

//if you change your query it retries the search

qs.write('some stuff')

output chunks will look like this:

//assuming get(q, cb) calls back a string
"samestuff not found",
"CLEAR", //this means new results
"stuff1",
"stuff2",
etc..

"CLEAR" is a special message. it means that the following is a new response, and the display should clear previous elements.

UI

Pipe a input field into this, and out to a list. NOTE, this stuff isn't implemented yet! But it will look something like this:

//input-stream creates a stream of DOM events.
inputStream('#query', 'onchange', function (e) {
  return e.value
}).pipe(qs)
//element stream adds elements to a given root Element.
.pipe(elementStream('#results', function (e) {
  if(e === 'CLEAR')
    return this.root.removeAllChildren()
  return '<li>'+e+'</li>'
})

## License

MIT
Something went wrong with that request. Please try again.