GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - coroutine/crom: A JS library that laughs at your four winds.

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
specs
specs
 
 
src/coffee
src/coffee
 
 
.gitignore
.gitignore
 
 
.nvmrc
.nvmrc
 
 
Gruntfile.coffee
Gruntfile.coffee
 
 
MIT-LICENSE
MIT-LICENSE
 
 
README.md
README.md
 
 
karma.conf.coffee
karma.conf.coffee
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

Crom

A JS library that laughs at your four winds.

Crom!

Example

Server Response

Below is our example JSON response from the RESTful API endpoint http://example.com/snakepits/1.json:

{
  "depth": 40,
  "units": "meters",
  "owner": {
    "name": "Crom",
    "title": "God of Steel"
  },
  "snakes": [
    {
      "length": "20",
      "units":  "meters",
      "isVenomous": true,
      "likes": "killing the shit out of people."
    },
    {
      "length": "12",
      "units":  "meters",
      "isVenomous": false,
      "likes": "long walks on the beach."
    }
  ]
}

Crom Models

And now, the corresponding Backbone Models, leveraging Crom:

Person

class Person extends Crom.Model
  defaults:
    name: null
    title: null

Snake

class Snake extends Crom.Model
  defaults:
    length: 0
    units: null
    isVenomous: false
    likes: null

Snakes (Collection)

class Snakes extends Crom.Collection
  model: Snake

Snakepit

class Snakepit extends Crom.Model

  # our glorious RESTful endpoint
  url: 'http://example.com/snakepits'

  defaults:
    depth: 0
    units: null

  # Here we have some nested data
  nested: ->
    owner:  Person
    snakes: Snakes

Putting it all together

Now we're able to put our models to the test:

snakepit = new Snakepit(id: 1)
snakepit.fetch()

snakepit.owner # -> an instance of the Person model
snakepit.snakes # -> an instance of the Snakes collection

About

A JS library that laughs at your four winds.

Topics

associationsbackbonejsmodel

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

5 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.