No more waitFor - Asynchronous server side rendering prelease

If you’ve been using models in your DoneJS app you’ve probably come to know/hate this pattern:

var ViewModel = can.Map.extend({
  define: {
    messages: {
      get: function(){
        return this.attr("%root").pageData("messages", {}, Message.getList({}));
      }
    }
  }
});

You might also have seen waitFor which does the same thing as pageData but doesn’t adding the result to the INLINE_CACHE.

We now have a new prerelease of can-ssr and done-autorender which eliminates the need to create these signals in your code. Instead we use a new project, can-wait, under the hood which tracks asynchronous tasks as part of the server side rendering request lifecycle.

What this means to you is that you can now write the same code as simply:

var ViewModel = can.Map.extend({
  define: {
    messages: {
      get: function(){
        return Message.getList({});
      }
    }
  }
});

Thanks to can-wait this request will be tracked and included in the INLINE_CACHE automatically.

This feature is now available in prereleases. To try it out you need:

  • can-connect 0.3.3
  • can-ssr 0.11.0-pre.0
  • done-autorender 0.6.0-pre.0

waitFor and pageData are currently supported, and likely will be on DoneJS 0.6.0, but might be removed in a future release of DoneJS. For now please try out the new versions of these packages and report any problems to https://github.com/donejs/donejs/issues

3 Likes