mondora / asteroid

An alternative client for a Meteor backend
MIT License
734 stars 101 forks source link

reactiveQuery result #75

Closed gillestasse closed 9 years ago

gillestasse commented 9 years ago

I am experimenting with asteroid.

My html looks like :

<!DOCTYPE html>
<html>
<head>
    <title>test</title>

<script src="bower_components/ddp.js/src/ddp.js"></script>
<script src="bower_components/q/q.js"></script>
<script src="bower_components/asteroid/dist/asteroid.browser.js"></script>
</head>
<body>

<script type="text/javascript">
    var ceres = new Asteroid("localhost:3000");
    var tasks = ceres.getCollection("movies");
    var _t=tasks._set
    console.dir(tasks._set._items) // line 15
    console.dir(tasks.reactiveQuery({}).result) //line 16

</script>

</body>
</html>

The chrome console gives me this output

one

Why can't I access the result of the Query ?

gillestasse commented 9 years ago

reactiveQuery is asynchronous. It makes total sense that nothing is printed out. I can use timeout .

setTimeout(function() {
    console.dir(movies.reactiveQuery({}).result)
}, 100);

Is there some event i can use that can notify when result are available ?