Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (27 sloc) 1.192 kb


_ = require 'underscore'

pagecontents = [
    { path: '/', contents: 'home' }
    { path: '/test', contents: 'test' }
    { path: '/about', contents: 'about' }

app.fetch.bind 'pagecontents', 'bypath', (app, params, cb) ->
    cb _(pagecontents).find (page) -> page.path is params.path

app.fetch.bind 'pagecontents', 'search', (app, params, cb) ->
    cb _(pagecontents).filter (page) ->
        (page.path.startswith params.term) or (page.contents.contains term)

What is the problem?

When writing systems the way data is retrieved is not related to the logic. As a result it's useful to have some form of separation. Additionally how the information is presented is not important to how the data is retrieved.

How fetching solves this problem

  1. A clear separation of where information comes from is provided app.fetch provides an interface to register and retrieve information.
  2. The results of this information can be made available as json, xml, or any other representation.
  3. Metadata is kept for debugging purposes.


  1. Simple
  2. One concept multiple specifications
Jump to Line
Something went wrong with that request. Please try again.