<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Orbit.js數(shù)據(jù)訪問和同步標(biāo)準(zhǔn)庫

          聯(lián)合創(chuàng)作 · 2023-09-22 11:01

          Orbit.js 是一個標(biāo)準(zhǔn)庫用于數(shù)據(jù)訪問和同步。Orbit 依賴于 Promises、Events 和底層轉(zhuǎn)換。

          簡單示例:

            // 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)
          瀏覽 29
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  成人淫色综合网站 | 日韩丝袜足交视频网站 | 精品多人P群无码视频 | 人人人人人草 | 2025最新操逼视频 |