Hi!

Well, I'm acutally using $loaded() about everywhere in my app. I need this
for plenty of reason. One of them is to build a "summary" object with
calculation made from a Firebase array.

In the API docs, in the $loaded section, there`s no mention of using
$loaded is a bad practice.

In the Introduction guide, I saw this statement this week-end:

It's also possible to do this directly in the controller by using the
$loaded()
<https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebaseobject-loaded> method.
However, this method should be used with care as it's only called once
after initial load. Using it for anything but debugging is usually a poor
practice.

Why? If this statement is still true, what is the alternative way of doing
some jobs aftger the object has been retrieved?

Thanks

VB

--
You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
To post to this group, send email to firebase-angular@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/f44ee551-481f-4a1f-920a-9c6bccd1ba73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Jacob Wenger at Sep 21, 2015 at 6:26 pm
    Hey Vincent,

    I think *"usually"* is the key word in the "usually a poor practice"
    phrase. There are certainly legitimate use cases for $loaded() and it seems
    like you have one. The reason we put that warning in the docs is that most
    users unintentionally misuse $loaded() and it leads to lots of support
    cases for us. In general, AngularFire handles the digest loop for you and
    you don't need to do anything after the data has actually loaded. It just
    magically appears in your view. Lots of people don't realize this at first.

    But rest assured, there are definitely legitimate uses for $loaded() (or
    else we wouldn't have included it in the API). Sorry for any confusion!

    Jacob
    On Mon, Sep 21, 2015 at 10:26 AM, Vincent Bergeron wrote:

    Hi!

    Well, I'm acutally using $loaded() about everywhere in my app. I need this
    for plenty of reason. One of them is to build a "summary" object with
    calculation made from a Firebase array.

    In the API docs, in the $loaded section, there`s no mention of using
    $loaded is a bad practice.

    In the Introduction guide, I saw this statement this week-end:

    It's also possible to do this directly in the controller by using the
    $loaded()
    <https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebaseobject-loaded> method.
    However, this method should be used with care as it's only called once
    after initial load. Using it for anything but debugging is usually a poor
    practice.

    Why? If this statement is still true, what is the alternative way of doing
    some jobs aftger the object has been retrieved?

    Thanks

    VB

    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/f44ee551-481f-4a1f-920a-9c6bccd1ba73%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/f44ee551-481f-4a1f-920a-9c6bccd1ba73%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/CAGcMwsAGmpidY5-8ZKb%2B6pLt%2BVpeTkBde42ZxA6tEHt_vmwrfg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Kato Richardson at Sep 22, 2015 at 3:02 pm
    Vincent,

    So here's an example of why using $loaded might get you into trouble. If
    you're building a summary object from the array, what happens if that data
    changes later?

    Are we discarding the array after loading the summary? If so, you probably
    didn't need $firebaseArray in the first place since you aren't using it for
    real-time bindings, and we probably could have just done a once('value') on
    the Firebase ref and created the summary.

    If we are keeping it around, the two could quickly become out of sync and
    this could create some oddness in your app. In which case, using the $$
    events and the $extend method would be preferable to using $loaded, since
    your summary would be kept up to date with the bound array.

    Thus, $loaded covers a pretty narrow use case (i.e. when you want to take
    an action after initial data is loaded, which is a one-time event that does
    not need to be kept in sync with changes to the bound data). And $extend
    should be used for more real-time use cases.

    Hopefully that adds some context to Jacob's advice and is more helpful than
    confusing. If not, share your use case and constraints and I can be more
    specific.

    ☼, Kato
    On Mon, Sep 21, 2015 at 11:25 AM, Jacob Wenger wrote:

    Hey Vincent,

    I think *"usually"* is the key word in the "usually a poor practice"
    phrase. There are certainly legitimate use cases for $loaded() and it
    seems like you have one. The reason we put that warning in the docs is that
    most users unintentionally misuse $loaded() and it leads to lots of
    support cases for us. In general, AngularFire handles the digest loop for
    you and you don't need to do anything after the data has actually loaded.
    It just magically appears in your view. Lots of people don't realize this
    at first.

    But rest assured, there are definitely legitimate uses for $loaded() (or
    else we wouldn't have included it in the API). Sorry for any confusion!

    Jacob
    On Mon, Sep 21, 2015 at 10:26 AM, Vincent Bergeron wrote:

    Hi!

    Well, I'm acutally using $loaded() about everywhere in my app. I need
    this for plenty of reason. One of them is to build a "summary" object with
    calculation made from a Firebase array.

    In the API docs, in the $loaded section, there`s no mention of using
    $loaded is a bad practice.

    In the Introduction guide, I saw this statement this week-end:

    It's also possible to do this directly in the controller by using the
    $loaded()
    <https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebaseobject-loaded> method.
    However, this method should be used with care as it's only called once
    after initial load. Using it for anything but debugging is usually a poor
    practice.

    Why? If this statement is still true, what is the alternative way of
    doing some jobs aftger the object has been retrieved?

    Thanks

    VB

    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/f44ee551-481f-4a1f-920a-9c6bccd1ba73%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/f44ee551-481f-4a1f-920a-9c6bccd1ba73%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/CAGcMwsAGmpidY5-8ZKb%2B6pLt%2BVpeTkBde42ZxA6tEHt_vmwrfg%40mail.gmail.com
    <https://groups.google.com/d/msgid/firebase-angular/CAGcMwsAGmpidY5-8ZKb%2B6pLt%2BVpeTkBde42ZxA6tEHt_vmwrfg%40mail.gmail.com?utm_medium=email&utm_source=footer>
    .

    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/CADypTEYB18%2BJSrzRgHQOQrJhCCv3K0eZ7Tii3pQKod8Zrbs6jA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupfirebase-angular @
postedSep 21, '15 at 2:26p
activeSep 22, '15 at 3:02p
posts3
users3

People

Translate

site design / logo © 2021 Grokbase