jeromegn/Backbone.localStorage
소개
Backbone.js용 localStorage 어댑터
기타 프로젝트측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- -3
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalBackbone localStorage Backend
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:
- Open an issue identifying the fault
- Provide a fix, with tests demonstrating the issue
- Run
npm test - Create a pull request
Acknowledgments
- Mark Woodall: Initial tests (now refactored)
- Martin Häcker: Many fixes and the test isolation
관련 프로젝트 살펴보기
불러오는 중…