Orbit.js 数据访问和同步标准库

程序名称:Orbit.js

Orbit.js 介绍

Orbit.js 是一个标准库用于数据访问和同步。Orbit 依赖于 Promises、Events 和底层转换。

简单示例:

  // Create data sources with a common schema
  var schema = {
    idField: '__id',
    models: {
      planet: {
      }
    }
  };
  var memorySource = new Orbit.MemorySource(schema);
  var restSource = new Orbit.JSONAPISource(schema);
  var localSource = new Orbit.LocalStorageSource(schema);

  // Connect MemorySource -> LocalStorageSource (using the default blocking strategy)
  var memToLocalConnector = new Orbit.TransformConnector(memorySource, localSource);

  // Connect MemorySource <-> JSONAPISource (using the default blocking strategy)
  var memToRestConnector = new Orbit.TransformConnector(memorySource, restSource);
  var restToMemConnector = new Orbit.TransformConnector(restSource, memorySource);

  // Add a record to the memory source
  memorySource.add('planet', {name: 'Jupiter', classification: 'gas giant'}).then(
    function(planet) {
      console.log('Planet added - ', planet.name, '(id:', planet.id, ')');
    }
  );

  // Log the transforms in all sources
  memorySource.on('didTransform', function(operation, inverse) {
    console.log('memorySource', operation);
  });

  localSource.on('didTransform', function(operation, inverse) {
    console.log('localSource', operation);
  });

  restSource.on('didTransform', function(operation, inverse) {
    console.log('restSource', operation);
  });

  // CONSOLE OUTPUT
  //
  // memorySource {op: 'add', path: 'planet/1', value: {__id: 1, name: 'Jupiter', classification: 'gas giant'}}
  // localSource  {op: 'add', path: 'planet/1', value: {__id: 1, name: 'Jupiter', classification: 'gas giant'}}
  // restSource   {op: 'add', path: 'planet/1', value: {__id: 1, id: 12345, name: 'Jupiter', classification: 'gas giant'}}
  // memorySource {op: 'add', path: 'planet/1/id', value: 12345}
  // localSource  {op: 'add', path: 'planet/1/id', value: 12345}
  // Planet added - Jupiter (id: 12345)

Orbit.js 官网

https://github.com/cerebris/orbit.js

相关编程语言

MuPlayer 是一款跨平台、轻量级的音频播放解决方案,...
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个...
DewPlayer音乐播放器,样式很简单,而且很实用.播放器...
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Fla...
Speakker 是一个基于 Web 浏览器的音乐播放器,只提...
Player Framework 是一个开源的支持 HTML5 的视频播...