本文整理汇总了TypeScript中@orbit/memory.update函数的典型用法代码示例。如果您正苦于以下问题:TypeScript update函数的具体用法?TypeScript update怎么用?TypeScript update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Adding a record to the memory source immediately pushes the update to the remote', async function(assert) {
assert.expect(1);
await coordinator.activate();
let planet: Record = {
type: 'planet',
id: schema.generateId(),
attributes: { name: 'Jupiter', classification: 'gas giant' }
};
fetchStub.withArgs('/planets').returns(
jsonapiResponse(201, {
data: {
id: planet.id,
type: 'planets',
attributes: { name: 'Jupiter', classification: 'gas giant' }
}
})
);
await memory.update(t => t.addRecord(planet));
let result = memory.cache.query(q => q.findRecord(planet));
assert.deepEqual(result, {
type: 'planet',
id: planet.id,
attributes: { name: 'Jupiter', classification: 'gas giant' }
});
});
开发者ID:orbitjs,项目名称:orbit.js,代码行数:31,代码来源:store-jsonapi-clientid-pessimistic-test.ts
示例2: update
update(
transformOrTransforms: TransformOrOperations,
options?: object,
id?: string
) {
return this.source.update(transformOrTransforms, options, id);
}
开发者ID:orbitjs,项目名称:ember-orbit,代码行数:7,代码来源:store.ts
示例3: test
test('Adding a record to the memory source queues an update request which will be pushed to the remote', async function(assert) {
assert.expect(2);
await coordinator.activate();
fetchStub.withArgs('/planets').returns(
jsonapiResponse(201, {
data: {
id: '12345',
type: 'planets',
attributes: { name: 'Jupiter', classification: 'gas giant' }
}
})
);
let planet: Record = {
type: 'planet',
id: schema.generateId(),
attributes: { name: 'Jupiter', classification: 'gas giant' }
};
await memory.update(t => t.addRecord(planet));
assert.deepEqual(
memory.cache.query(q => q.findRecord(planet)),
{
type: 'planet',
id: planet.id,
attributes: { name: 'Jupiter', classification: 'gas giant' }
},
'keys have not been syncd up yet - remote source still needs to process request'
);
await remote.requestQueue.process();
assert.deepEqual(
memory.cache.query(q => q.findRecord(planet)),
{
type: 'planet',
id: planet.id,
keys: { remoteId: '12345' },
attributes: { name: 'Jupiter', classification: 'gas giant' }
},
'keys are syncd up after remote source finishes processing requests'
);
});
开发者ID:orbitjs,项目名称:orbit.js,代码行数:45,代码来源:store-jsonapi-remoteid-optimistic-test.ts
示例4: test
test('Adding a record to the memory source immediately pushes the update to the remote', async function(assert) {
assert.expect(3);
await coordinator.activate();
fetchStub.withArgs('/planets').returns(
jsonapiResponse(201, {
data: {
id: '12345',
type: 'planets',
attributes: { name: 'Jupiter', classification: 'gas giant' }
}
})
);
let planet: Record = {
type: 'planet',
id: schema.generateId(),
attributes: { name: 'Jupiter', classification: 'gas giant' }
};
await memory.update(t => t.addRecord(planet));
let result = memory.cache.query(q => q.findRecord(planet));
assert.deepEqual(result, {
type: 'planet',
id: planet.id,
keys: { remoteId: '12345' },
attributes: { name: 'Jupiter', classification: 'gas giant' }
});
assert.equal(
keyMap.idToKey('planet', 'remoteId', planet.id),
'12345',
'id mapped to key'
);
assert.equal(
keyMap.keyToId('planet', 'remoteId', '12345'),
planet.id,
'key mapped to id'
);
});
开发者ID:orbitjs,项目名称:orbit.js,代码行数:42,代码来源:store-jsonapi-remoteid-pessimistic-test.ts
注:本文中的@orbit/memory.update函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论