• Stars
    star
    1,897
  • Rank 24,354 (Top 0.5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 14 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A localStorage adapter for Backbone.js

Backbone localStorage Backend

Build Status Coverage Status npm version

An adapter that replaces Backbone.sync to save to window.localStorage instead of to the server.

Note Backbone LocalStorage v2 changes the API to work more with ES6 modules. See Upgrade Notes for more details.

Usage

Import backbone.localstorage and attach it to your models and collections:

import {Collection, Model} from 'backbone';
import {LocalStorage} from 'backbone.localstorage';

const SomeCollection = Collection.extend({

  localStorage: new LocalStorage('SomeCollection'), // Uniquely identify this

});

const SomeModel = Model.extend({

  localStorage: new LocalStorage('SomeModel')

});

To synchronise with the server, you can pass the ajaxSync flag to any options:

const myModel = new SomeModel();
myModel.fetch({
  ajaxSync: true  // Fetches from the server
});

myModel.save({
  new: "value"
}, {
  ajaxSync: true  // Pushes back to the server
});

Upgrade Notes

Backbone LocalStorage is now built using ES6. It should be fully compatible with v1 with one difference: Instead of exporting the LocalStorage class as a default module, v2 exports it as a named variable. Below are examples covering the changes:

JavaScript ES5

In v1:

var LocalStorage = require('backbone.localstorage');

In v2:

var localStorage = require('backbone.localstorage');
var LocalStorage = localStorage.LocalStorage;

JavaScript ES6+

In v1:

import LocalStorage from 'backbone.localstorage';

In v2:

import {LocalStorage} from 'backbone.localstorage';

Contributing

Install NodeJS and run yarn or npm i to get your dependencies, then:

  1. Open an issue identifying the fault
  2. Provide a fix, with tests demonstrating the issue
  3. Run npm test
  4. Create a pull request

Acknowledgments

More Repositories

1

DocumentUp

Pretty documentation generator for Github projects with proper Readme.
Ruby
886
star
2

slang

Slim-inspired templating language for Crystal
Crystal
232
star
3

kilt

Generic template interface for Crystal
Crystal
148
star
4

localtodos

Simple Todos App built on Backbone.js
JavaScript
99
star
5

protobuf.cr

Protobuf generator, encoder and decoder.
Crystal
95
star
6

poutine

MongoDB ORM for Node.js
CoffeeScript
35
star
7

docker.cr

Docker API client in Crystal.
Crystal
26
star
8

influxdb.cr

InfluxDB driver for Crystal
Crystal
25
star
9

bson.cr

BSON implementation written in Crystal
Crystal
24
star
10

v8.cr

V8 bindings for Crystal
C++
16
star
11

dry-types-rails

Dry::Types railties
Ruby
11
star
12

beautifier

A safari extension which smooths fonts!
10
star
13

Warping-Shadow-CSS3

Warping Shadows can be done in CSS3
Ruby
8
star
14

mongol

Light modeling for MongoDB.
JavaScript
8
star
15

jeromegn.github.com

Personal site
HTML
5
star
16

rapid

Redis ORM-ish api for nodejs
JavaScript
3
star
17

backbone.pjax

Backbone utilities for web apps using PJAX.
JavaScript
3
star
18

rhai-tpl

Simple template engine using rhai for logic
Rust
2
star
19

qml.cr

QML library for Crystal
Crystal
2
star
20

quinn-plaintext

QUIC pluggable crypto to use the protocol as plaintext (for use when cryptography is already handled at another layer, e.g. Wireguard)
Rust
1
star
21

lg-ultrafine-brightness

Control LG Ultrafine brightness on linux
Rust
1
star
22

containerd-rs

Rust
1
star
23

Radiophonique

Objective-C
1
star
24

documentup.js

experimental DocumentUp running on fly.io
JavaScript
1
star
25

portfolio

My portfolio, built with StaticMatic
JavaScript
1
star
26

node-api-boilerplate

Simple Node.js API server boilerplate using CoffeeScript and Express
CoffeeScript
1
star