Comments (11)
It seems that it's expected with fixtures: you can't load it twice. (handled by fixtures.hasLoaded property - fixture_adapter.js).
from data.
hasLoaded goes back to undefined before setting the new data in App.Person.FIXTURES. Other than that, the code is shared between all adapters.
from data.
So, I looked it over and it seems that in store.updateModelArray we have:
if (shouldBeInArray && !alreadyInArray) {
modelArrays.add(array);
content.pushObject(clientId);
} else if (!shouldBeInArray && alreadyInArray) {
modelArrays.remove(array);
content.removeObject(clientId);
}
but when it should update the data it has shouldBeInArray as true and alreadyInArray as true also. And this case isn't being considered in the code.
But I'm not sure how I should proceed here. "content" seems to have a list of indexes but what about "modelArrays"? I'm not sure what it suppose to be or do. I know it's a SC.OrderedSet but in my example modelArrays.list has 2 objects and there is 4 in my store. I need some tips here. Thanks.
from data.
I've done something that seems to work:
updateModelArray: function(array, filter, type, clientId, hash) {
var shouldBeInArray;
if (!filter) {
shouldBeInArray = true;
} else {
shouldBeInArray = filter(hash);
}
var content = get(array, 'content');
var alreadyInArray = content.indexOf(clientId) !== -1;
var modelArrays = this.modelArraysForClientId(clientId);
if (shouldBeInArray && !alreadyInArray) {
modelArrays.add(array);
content.pushObject(clientId);
} else if (!shouldBeInArray && alreadyInArray) {
modelArrays.remove(array);
content.removeObject(clientId);
} else if (shouldBeInArray && alreadyInArray) {
var models = get(this, 'models');
this.didUpdateModel(models[clientId], hash);
}
},
The last "else if" being the relevant part.
What do you think?
from data.
It seems that bbf044b should fix this as well. I'll try that monday.
from data.
I'm closing this ticket. If it's still an issue, please let me know.
from data.
Well, I updated the jsfiddle to use the last changes: http://jsfiddle.net/5n2LU/8/
But it doesn't work yet.
findMany calls loadMany internatlly in the fixtureAdapter, so it should update those records in the store, but that's not happening.
from data.
The semantics of findMany are that if the IDs are already in the store, the store doesn't go back to the adapter to get more data.
from data.
Al'right, but loadMany
shouldn't update the store?
Even tho there is a if (fixtures.hasLoaded) { return; }
in the code, hasLoaded
is undefined
in the jsfiddle example in both findMany
calls.
findMany
will call find
that will call loadMany
. Here it is the code I'm talking about:
find: function(store, type, id) {
var fixtures = type.FIXTURES;
ember_assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
if (fixtures.hasLoaded) { return; }
setTimeout(function() {
store.loadMany(type, fixtures);
fixtures.hasLoaded = true;
}, 300);
}
from data.
I really think the else if
that I mentioned earlier in this thread, inside the updateModelArray
function, is a case that is not being dealt and seems the source of this problem.
from data.
Since another person in the IRC channel had this problem:
how can i refresh data of ember-data?? i loaded an array of items with find and now i would like to refresh them?
should i use findMany?? calling again findAll does not request anything, i assumed is returning the cache```
He managed to update the records:
for findAll i fixed by Yn.store.typeMapFor(Yn.Product).findAllCache = null;```
But that doesn't seem right. Is it?
from data.
Related Issues (20)
- broken docs link HOT 3
- docs: turning store.request document into record(s) is not documented HOT 1
- BUG: Cannot set host relative to site root
- bug: Setting hasMany relationship IDs to an array with duplicate IDs should error HOT 1
- return type of peekRequest is incorrect in the api docs
- is there a design flaw in request lifetimes? HOT 9
- design issue: fetch handler doesn't provide response on error HOT 3
- bug: typescript error when using computed properties in conditionals HOT 1
- bug: async-to-async relationships may error when using `unloadAll` on both types HOT 12
- Preloading polymorphic relationship breaks on ember-data 5.3 HOT 2
- Feat - Additional Functionality Support in RequestManager for handler for Dynamic Handling beyond 'request' HOT 3
- Broken link in JSON Api ReadMe HOT 1
- cache.rollbackRelationships does not rollback the 2nd time after adding a record and rollback again HOT 3
- Understanding polymorphism HOT 2
- Assertion after saving a new relational record and tried to forget it HOT 4
- [3.28->4.7] `isLoaded` does not recompute if checked before the record has loaded. HOT 6
- Error `Could not find module `@warp-drive/core-types/request` imported from `(require)`` after update to 5.3.1 HOT 15
- ember-data date transform: triggering change on record re-insertion HOT 6
- bug: not tracking changes to empty relationship in 5.3.1+
- Breaks yarn install on Windows HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data.