fetching

0.0.2 • Public • Published

Fetching

= 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.

Goals

  1. Simple
  2. One concept multiple specifications

Readme

Keywords

none

Package Sidebar

Install

npm i fetching

Weekly Downloads

0

Version

0.0.2

License

none

Last publish

Collaborators

  • tcoats
  • tornadot-tim