I was under the impression this data would be loaded when called.
What do you mean by "called"?
It would be more correct to say "loaded when needed".
Consider the following:
// parent-model
children: hasMany('children', { async: true })
// parent-controller
displayChildren: false
// child-model
name: attr()
// template
{{#if displayChildren}}
{{#each model.children as |child|}}
{{child.name}}
{{/each}}
{{/if}}
Since displayChildren
is false, the loop in the template will not be executed. Hence the children are not needed. Hence they will not be retrieved. When displayChildren
is set to true, the children become needed by the template, and will be retrieved. If the initial value of displayChildren
is true, the children will be retrieved instantly upon rendering.
There is one other situation in which the records referred to by the async relationship will be loaded: when get
is called for them (which is sort of what happens under the covers when the template tries to get them). This get
will return a promise for the actual value. So if for some reason you need or want to access the children from program logic, you write something like this:
// parent-controller
someFunc() {
this.get('model.children') . then(children => /* do something with children */)
}