- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/ClickerMonkey/neurosync
- 软件文档: https://github.com/ClickerMonkey/neurosync
软件介绍
Neurosync 是一个 JavaScript ORM 库,支持离线和实时操作。没错,是 ORM,但并没有疯狂到直接连接到后台数据库。对 Neurosync 来说,数据库就是后端的 REST API,而 Neurosync 就是这个 API 的一个门面。
Neurosync 的生命周期非常简单:
保存数据变更到本地存储
发起 REST 请求
如果请求成功则删除本地存储中的变更数据,标识为已保存,并发布到实时 API
如果请求失败,因为应用本身是离线的,将等待应用在线并继续处理数据更改流程
如果有待决的操作但是应用重启了,数据将会被恢复
一个简单的 TODO 应用示例代码:
var Todo = Neuro({
name: 'todo',
api: '/api/1.0/todo/',
fields: ['name', 'finished_at'],
timestamps: true,
comparator: ['-finished_at', '-created_at'], // finished go to bottom, most recently created are at the top
methods: {
finish: function(finished) {
this.$save('finished_at', finished ? Date.now() null);
}
},
dynamic: {
done: function() {
return !this.finished_at;
}
}
});
var t0 = Todo.create({name: 'Download Neurosync'});
t0.$isSaved(); // true
t0.finish( true );
t0.done; // true
t0.$remove();
var t1 = new Todo({name: 'Use Neurosync'});
t1.$isSaved(); // false
t1.id; // UUID
t1.$save();
var t2 = Todo.boot({id: 34, name: 'Profit'}); // Todo data that already exists remotely
t2.$isSaved(); // true
t2.name = '???';
t2.$hasChanges(); // true
var t3 = Todo.fetch(45); // REST call if doesn't exist locally
Todo.all(); // [t1, t2, t3]
Todo.collect(t1, t2); // creates a collection of todos
var allRemote = Todo.fetchAll(function(all) {}); // call REST API
var f0 = Todo.find('name', 'Download Neurosync'); // first match
var f1 = Todo.find({done: true});
var w0 = Todo.where('done', true); // all done todos
var w1 = Todo.where({finished_at: null});
var g0 = Todo.get(34); // get cached version
var g1 = Todo.grab(34); // get cached version, otherwise call REST API
var a0 = Todo.grabAll(function(all) {}); // get all cached, if none cached call REST API
Todo.ready(function() {}); // when it has been initialized locally and/or remotely (depends on options).
Todo.refresh(); // re-fetch from REST API
var search0 = Todo.search({done: true}); // sends a search to the REST API (POST by default)
var searchPaged0 = Todo.searchPaged({done: true, page_offset: 0, page_size: 20});
searchPaged0.$next();
创业的艺术2.0
〔美〕盖伊·川崎 / 刘悦、段歆玥 / 译言·东西文库/电子工业出版社 / 2016-9 / 68
“创业者导师”——盖伊•川崎的《创业的艺术2.0》被阿丽亚娜•赫芬顿评为“终极的创业手册”。无论您是企业家、小企业主、企业开拓者还是非盈利组织的领导人,都可以让你的产品、服务或理念获得成功。 盖伊选取了不用角度,探索前十年商界的巨大变化,并寻求解决之道。曾经所向披靡的市场巨头深陷水深火热之中,社交媒体也取代了人际关系和广告,成为营销推广的主要渠道。众筹也成为广大投资者的可行之举。“云”更是每......一起来看看 《创业的艺术2.0》 这本书的介绍吧!
