Documentation unclear about autoFetch use in conjunction with model fetch #278

Closed
ferrouswheel opened this Issue Feb 27, 2013 · 5 comments

Comments

Projects
None yet
3 participants
@ferrouswheel

Let's say I have a Backbone.HasMany/One relation 'Animals' on Zoo, defined as:

Zoo = Backbone.RelationalModel.extend({
        relations: [
            {
                type: Backbone.HasOne,
                key: 'animal',
                relatedModel: AnimalModel,
                autoFetch = {success: function() {model, response} { ... }
           }],
...
}

I then use Zoo.fetch(success: function() { ... }) to initialise things.

To me it is non-obvious that the Zoo.fetch success function is called before the autoFetch success. Intuitively, I would expect that fetch's success would only be called once all relations have been autoFetched (not to mention, how can success be assured? An autofetched relation might result in error?).

If this can't/won't be changed, then a note in the documention would be great to save people some hours of frustration ;-)

Also, autoFetch is missing from the table of contents pane of the documentation.

@PaulUithol

This comment has been minimized.

Show comment Hide comment
@PaulUithol

PaulUithol Mar 1, 2013

Owner

The autoFetch option is not much more than "just another" fetch that happens to be fired automatically once your model has been fetched.

Is there anything in particular in the docs that gave you the idea it was something else? Some wording we can clarify?

Owner

PaulUithol commented Mar 1, 2013

The autoFetch option is not much more than "just another" fetch that happens to be fired automatically once your model has been fetched.

Is there anything in particular in the docs that gave you the idea it was something else? Some wording we can clarify?

@ferrouswheel

This comment has been minimized.

Show comment Hide comment
@ferrouswheel

ferrouswheel Mar 2, 2013

It'd be great to just note that when the model is fetch()'ed, it's autoFetch relations are fetched after.

I.e. that the original fetch's success callback is not deferred until after all relations are succesfully fetched.

I don't think it's unreasonable for people to expect that the original fetch() success callback will only be called when the model and it's autoFetch relations have all been successfully fetched (unless I'm missing some grander design assumption that implicitly covers this situation).

It'd be great to just note that when the model is fetch()'ed, it's autoFetch relations are fetched after.

I.e. that the original fetch's success callback is not deferred until after all relations are succesfully fetched.

I don't think it's unreasonable for people to expect that the original fetch() success callback will only be called when the model and it's autoFetch relations have all been successfully fetched (unless I'm missing some grander design assumption that implicitly covers this situation).

@PaulUithol

This comment has been minimized.

Show comment Hide comment
@PaulUithol

PaulUithol Mar 5, 2013

Owner

That'd be the "Keep It Simple" design principle ;). For example, I wouldn't expect fetch to fail if a relation didn't autoFetch correctly, the possibility of nested autoFetch of relations of relations, etc. Added a note to the docs just now, will be live with the next version.

Owner

PaulUithol commented Mar 5, 2013

That'd be the "Keep It Simple" design principle ;). For example, I wouldn't expect fetch to fail if a relation didn't autoFetch correctly, the possibility of nested autoFetch of relations of relations, etc. Added a note to the docs just now, will be live with the next version.

@PaulUithol PaulUithol closed this in d918e45 Mar 5, 2013

@ferrouswheel

This comment has been minimized.

Show comment Hide comment
@ferrouswheel

ferrouswheel Mar 6, 2013

👍 Thanks!

👍 Thanks!

@sarink

This comment has been minimized.

Show comment Hide comment
@sarink

sarink Nov 7, 2013

The docs are ambiguous.

Does a model's related objects get autoFetch'ed on instantiation of that model, or on fetch() of that model?

sarink commented Nov 7, 2013

The docs are ambiguous.

Does a model's related objects get autoFetch'ed on instantiation of that model, or on fetch() of that model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment