Comments (4)
@opsb You are correct that relationships are synchronously populated from the source. However, it's possible to asynchronously fetch them, as described in the README:
A model's relationships can be re-queried by calling reload() on a relationship object. This triggers the associated findLink call and returns its promise. Related records will be updated through transformations to the underlying source. Any changes should be reflected by the time the promise resolves.
For example:
planet.get('moons').reload().then(function() {
console.log(planet.get('moons.length'));
});
Please re-open if you have any problems.
from orbit.
I did see that, if a view is showing a nested object graph though it's a bit cumbersome to have to go through the graph and call reload() on each relationship. In my case I'm now solving it by adding firebase listeners to each relationship when a record is loaded. That way they're loaded immediately and keep up to date with server side changes. This works fine for me but I think lazily loaded relationships would be worth addressing at some point, in particular with the JSON-API adapter.
from orbit.
Eager fetching is something that needs to be carefully controlled or else it will get out of control. However, I can imagine it can be controlled given the right configuration settings.
One scenario I could imagine is providing hooks to specify different include
params in the JSONAPISource, depending on the type requested. Furthermore, we could extend schemas in orbit to allow per-source configuration data to be stored for each type. And that configuration data could flow from model definitions in ember-orbit.
from orbit.
Firebase makes great claims about being very efficient with regards to adding a large number of listeners, I'm building the Source based on this assumption initially but I'll see how it runs with my app and make it more intelligent if necessary.
With regards to specifying include params on a per type basis, I'd say that one of the major issues I had with ember-data is that it's not possible to specify includes on a per-scenario basis. I found this an extremely difficult juggling act as it meant loading up lots of unnecessary information when showing list views for instance. Bearing that in mind and considering that relationships are implemented as proxies it might be nice to allow something like:
persons.projects.includes(['members']);
I've had rails like scopes for relationships in the back of my mind for a while now, it's something that I'll take a look at when I've got some time.
from orbit.
Related Issues (20)
- Memory Cache won't update relationships' meta if identities match existing record HOT 6
- Enable GitHub discussions to move support requests/general questions out of issue queue HOT 2
- [Docs] Add technical description of key request-processing, sync components
- `JSONAPIURLBuilder::buildPageParam()` (and likely others) have undefined properties serialized as `undefined` in query param
- Improve Validation Errors
- Integration with AbortSignal HOT 1
- serializers customization HOT 1
- custom filter operations
- [Feature] AsyncStorage data source
- Allow filtering for attribute/relationship not `null` (negated condition)
- Add "sideEffects": false to Orbit packages HOT 3
- Need optional chaining in `MemoryCache::removeInverseRelationshipsSync()` HOT 4
- jsonapi parallel request HOT 1
- parallel data querying principes HOT 3
- There is no upgrading steps in documentation HOT 2
- JSONAPISource Serialization Problem
- Store `__inverseRels__` not cleaned up with transform option `{ useBuffer: true }` HOT 1
- Optimistic Error Handling Got TypeError Not NetworkError HOT 4
- "supportsIndexedDB" is malfunctioning in some cases
- Kalakyo HOT 1
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 orbit.