[Resolved] How to force refresh a reactive datasource in handlebars?


#1

Hi,

I got a mongoDatabase bind on a table and i would like to refresh hime quicker than he does at the moment.
For now, when I’m adding something in the db, the refresh can take around 10 litles seconds to react in my meteor table, but i’m notified in the code than my new record is displayable.

Here some code :

Html :

<table class="table table-striped table-hover " >
      <thead>
            <tr>
                 <th>Login</th>
            </tr>
      </thead>
      <p>Last updated : {{lastUpdate}}</p>
      {{#each userList}}
             <tr class="terminalHS6_userClickable">
                  <td class="userLoginLeft"> > {{login}}</td>
             </tr>
      {{/each}}
</table>

Js :

Template.registerHelper('userList', function () {
     return _telnet_users.find({});
});

isOK = function(){
    // Here I want to refresh my table to display my new record quickly !
}

I tried to played with Session variable, subcription.ready() etc… and Deps.autorun to force it, but hadn’t chance until there ! :’(
Any idea how can I proceed ?
Thanks


#2

So did I understand you right, f.e. you add a user and it takes up to 10 seconds, until the new user is displayed in the table? In this case, you need to enable oplog tailing for your database.


#3

Yep, you’re right, that the problem :slight_smile:

I understand your solution. Maybe it could works, but it’s seems to be excessive just to win around 5sec… :o
I’m really surprised it’s not doable to refresh a double moustache to rerequest his data.


#4

Maybe a solution could be to stop the subscription and subscribe again to the data, so for example:

var myUserSub = Meteor.subscribe("myUserPublish");

function refresh() {
myUserSub.stop();
myUserSub = Meteor.subscribe(“myUserPublish”);
}


#5

Wow… it’s a dummy solution but very effective !
I mean by this, why did I thank about that ?! :slight_smile:
Thanks a lot XTA