Please have a look at Upcoming Async Router API which provides an API to make all of this much easier to do.