fluidinfo/infomaniac — pull request #11 by jkakar (2012-03-14 23:16:05+00:00)
Title: separate-concerns-10

This branch introduces the following changes:

- I've refactored the extension logic around the MVC pattern. I've
put classes in place to represent all the pieces in the pattern,
with the logic in the right place, and for the most part it's pretty
straight-forward. There is some annoying scope-management logic
spread across a few places, to ensure that `this` is set to the
correct object, because Javascript sucks.

- The underlying design is basically the same as before, though
there's an interesting/important difference: the data we get from
Fluidinfo is cached in `Webpage` instances. There is a `Webpage`
instance for each page the user opens. There are some nice benefits
to this:
- We don't have to query Fluidinfo each time you switch tabs, as we
did before. This means we avoid unnecessary load on Fluidinfo and
have really fast sidebar updates, instead of needing to deal with
latency before updating the view.
- The logic to get a `Webpage` instance is asynchronous. This makes
the code a bit verbose, because we have to write callbacks
everytime we want to do something with a `Webpage` instance. On
the other hand, in the future we can add simple `setTimeout` calls
to invalidate the cache every N minutes. This will allow us to
manage memory effectively (by not storing `Webpage` instances for
every page you every opened forever) and also to cause automatic
refreshes from Fluidinfo so that a long-running tab will always be
close to up-to-date.

- There's nothing in place yet, but the refactoring of the logic here
should make it easy to write unit tests for the non-UI-related bits
of the code. I plan to do some experimenting in that area in the
coming days.

This branch is stacked on `jkakar/link-to-fluidinfo-8`.

Fixes #10.