Amplify.js を Knockout.js で使用しており、データをローカルに保存したいと考えています。このコードを使用してみました:ガイドを増幅します が、うまくいきません。
私のビューモデル
define(['services/datacontext'], function (dataContext) {
var store = amplify.store("offlineData"); // Why is agency undefined after retrieving from the store?!?!?!
var agency = ko.observableArray([]);
var initialized = false;
var save = function (agency) {
return dataContext.saveChanges(agency);
};
var vm = { // This is my view model, my functions are bound to it.
//These are wired up to my agency view
activate: activate,
agency: agency,
title: 'agency',
refresh: refresh, // call refresh function which calls get Agencies
save: save
};
return vm;
function activate() {
if (initialized) {
return;
}
initialized = true;
if (initialized == true) {
amplify.store("offlineData", vm.agency);
}
return refresh();
}
function refresh() {
return dataContext.getAgency(agency);
}
});
更新によってデータが取得されたら、このデータをローカル ストアに保存します。したがって、このページに対して別のリクエストを行うと。var ストアにこのデータが含まれていることを期待しますが、未定義です。
増幅の使い方を知っている人はいますか?