title: Knockout viewmodel returning function (how to?)
body: <p>I have an application that displays messages from a database. Using Breeze.js for serverside API controller and Knockout.js for databinding.</p>
  
  <p>Initially we get 30 messages and from then every 30 second we get the latest messages that were inserted in the database.</p>
  
  <pre><code>    function messageViewModel() {
      var self = this;
      var refreshRate = 5000;
      var lastMessageID = null;
      self.allMessages = ko.observableArray();
  
      var query = breeze.EntityQuery.from('Messages').orderByDesc('Id').expand('Poster').take(20);
      manager.executeQuery(query)
          .then(function(messages) {
              self.allMessages(messages.results);
              lastMessageID = messages.results[0].Id();
              window.setInterval(refresh, refreshRate);
          }).fail(function(error) {
              alert(error.message);
          });
  
     function refresh() {
          query = breeze.EntityQuery.from('Messages').orderByDesc('Id').where('Id', '&gt;', lastMessageID).expand('Poster');
          manager.executeQuery(query)
              .then(function (newMessages) {
                  if (newMessages.results.length != 0) {
                      for (var count = 0; count &lt; newMessages.results.length; count++) {
                          self.allMessages.unshift(newMessages.results[count]);
                          lastMessageID = newMessages.results[0].Id();
                      }
                  }
              }).fail(function (error) {
                  alert(error.name+" "+error.message);
              });
      }
  }
  
  return {
      getPosterByCallsign: getPosterByCallsign,
      MessageViewModel: messageViewModel,
      postMessage: postMessage,
  }
  </code></pre>
  
  <p>I  would now like to be able to call the refresh method from another js module. How can i achive this? The viewmodel is called from an module like this:</p>
  
  <pre><code>define(["common/dataService"], function(n0uk) {
  $(document).ready(function() {
      ko.applyBindings(new n0uk.MessageViewModel());
  
      $('#postButton').click(function() {
          n0uk.postMessage(window.message);
      });
      $('#message').keypress(function(e) {
          if (e.which == 13) {
              n0uk.postMessage(window.message);
              e.preventDefault();
          }
      });
  });
  </code></pre>
  
  <p>});</p>
  
  <p>The refresk should be called after the n0uk.postMessage() call....</p>