Reputation: 1174
What is the best approach to rerun a server query/subscription for a specific connected client when some data on that client changes?
This would be very useful for server side filtering, ordering or paging.
For example, the client has a table with thousands of lines that are paginated, when the user changes the filtering text or page number the server would recompute the query subscription with that filter, and update the client on the fly.
The search input doesn't have to be synced across all connected users of the server, and thus its not needed to be present in the database.
Is there any way to perform this with traditional model methods on both client and server or do I have to implement a RPC like approach as mentioned in the FAQ?
Thanks!
Upvotes: 2
Views: 148
Reputation: 21
var filter = model.root.filter('items', 'temp.pageNumber', function(item, x,y,pageNumber){
if (item.index > pageNumber*10 && item.index < pageNumber*10+10){
return true;
}
return false;
}
model.root.subscribe(filter,function(){
model.ref('filteredItems', filter);
});
and bind to filteredItems in view. something like this.
Upvotes: 0