drewww/unhangout — pull request #231 by yourcelf (2013-11-18 23:40:51+00:00)
Title: Refactor DB loading for deterministic order

Refactor the DB loading for two reasons:

1. The current loading depends on the order of reading keys from an
object, which is problematic, as that ordering is undefined. If
`sessions` were loaded prior to `events` this would cause problems. Use
an array rather than object to store loaders.

2. Clarify the heavily nested loading function. This new implementation
is a bit more verbose, but I hope clearer:

- use `async.waterfall` to control flow rather than nesting callbacks.
- use `async.map` and `async.mapSeries` rather than nesting
`async.parallel(_.map(...))`, etc.
- use `that = this` as strategy for enclosing `this` rather than
`_.bind`. I'm a fan of `_.bind`, but when it gets 3 levels deep, it
just gets hard to read.