You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you are getting something from a store, you must assume it will require an asynchronous operation to fetch the data (right now we are only concerned with HTTP requests). Currently if we don't have the data yet we send off an HTTP request and return null/undefined. This approach leaves a number of unanswered questions
How do you differentiate from the entity not being in the local cache and it not existing at all (e.g. 404/410)
How you know if there is already an HTTP request in progress which is trying to get the data?
How do you know if an HTTP request has failed?
How do you ensure all the stores are synchronised before returning the result of a asynchronous result?
If a views initial state is not available before the component is mounted, what should we render?
The text was updated successfully, but these errors were encountered:
var FooCache = Marty.createCache({
mixins: [Marty.HttpCache],
getById: function (id) {
return this.lock(id, function () {
if (this.contains(id)) {
return this.state[id];
}
return this.get('/foos/' + id)
});
}
});
var FooStore = Marty.createStore({
mixins: [HttpCache],
getFoos: function (id) {
this.getById(id)
}
});
var FooState = Marty.createStateMixin({
getState: function () {
return {
// if any state values is promises, we wait for them to be resolved
foo: FooStore.getFoo(id)
};
}
});
var FooView = Marty.createStateMixin({
mixins: [FooState],
render: function () {
}
})
When you are getting something from a store, you must assume it will require an asynchronous operation to fetch the data (right now we are only concerned with HTTP requests). Currently if we don't have the data yet we send off an HTTP request and return null/undefined. This approach leaves a number of unanswered questions
The text was updated successfully, but these errors were encountered: