0
私はEmberアダプターを持っており、モデルとストアにデータを送るために私のAPIに接続します。問題は私のAPIのアドレスが "理由"のために変わることができることです。どのようにして私のアダプタを更新して、ストアの変更によってホストが更新されるのですか?ホストを変更しても、アダプターは次回にHTTP要求を作成する必要がある新しいホストを使用しますか?ここでEmberアダプターの更新ホスト
は私が店の変化を見ている観測者があり、その後、ApplicationAdapterの静的メソッドを呼び出します...
const ApplicationAdapter = RestAdapter.extend({
namespace: 'api',
host: "0.0.0.0"
});
ApplicationAdapter.reopenClass({
updateHost(host) {
console.log("Here: " + host);
//Both of these throw an error probably because host is not static
//this.set('host', host); I attempted this first
//this.host = host; Then I attempted this way
}
});
export default ApplicationAdapter;
を試してきたものです。
export default Model.extend({
ip1: attr('string'),
ip2: attr('string'),
ip1Observer: Ember.observer('ip1', function() {
let newValue = this.get('ip1');
ApplicationAdapter.updateHost(newValue);
}),
ip2Observer: Ember.observer('ip2', function() {
let newValue = this.get('ip2');
ApplicationAdapter.updateHost(newValue);
})
});
必要に応じてモデル固有のアダプタを書くことができることを忘れないでください。 – kumkanillam