Giter VIP home page Giter VIP logo

Comments (6)

posva avatar posva commented on May 18, 2024

I honestly don't know. I tried it in a fiddle based on the demo and it just works fine: https://jsfiddle.net/posva/r3ab21nm/

Maybe you can try fiddling around to see where the issue is coming from. If you find a bug, please tell me here or better off, open a new issue with the repro

from vuefire.

thedangler avatar thedangler commented on May 18, 2024

I think I was able to reproduce it with simpler code.
HTML
`

        <ul>
        <li v-for="team in teams">{{ team.name }}</li>
        </ul>
        
        <pre>
        {{ firstPlaceTeam.name }}
        </pre>
    </div>`

JS

` var teamsRef = db.ref('teams');

  var app = new Vue({
    
    el: '#app',
    data : function(){ return { news: [] }},
    firebase : {
    
        teams : teamsRef.limitToLast(7)
    
    },
    computed: {
        
        firstPlaceTeam  : function(){
            
            return this.teams[0];
            
        }
        
    }
    
    
    });`

I'm not getting undefined like I originally was, I'm wondering if its all tied together somehow.

When I run it the name prints out but I get errors.
Error when rendering root instance:
Uncaught TypeError: Cannot read property 'name' of undefined

Since the errors happen it breaks the js and it stops working. I'm wondering if that is what is going on.

In your js fiddle example I did changed it to print filtered.text and the error console showed the same error.

from vuefire.

posva avatar posva commented on May 18, 2024

That's because of {{ firstPlaceTeam.name }} you need to check firstPlaceTeam first as it may be undefined: {{ firstPlaceTeam && firstPlaceTeam.name }}

from vuefire.

thedangler avatar thedangler commented on May 18, 2024

Thanks you.
Ill try my program tonight see if that's the culprit.

from vuefire.

greatramu avatar greatramu commented on May 18, 2024

@thedangler hi.. i think that is because the computed property is depending on the array populated by firebase. it looks like the computation is running too soon, before the firebase could finish fetching data.

@posva is it possible to include a optional doneCallback() callback, similar to cancelCallback? This doneCallback could be called after the async operations of firebase are completed and the properties in the vm are updated. This will be very useful to avoid issues like the above mentioned one. Also, it can be used to show status to user while loading the data from remote firebase server.

from vuefire.

posva avatar posva commented on May 18, 2024

hi.. i think that is because the computed property is depending on the array populated by firebase. it looks like the computation is running too soon, before the firebase could finish fetching data.

The array is synchronously initialised to an empty array

About the doneCallback, I want to add something similar but not the for the same reasons.

from vuefire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.