windrobin / timemap

Automatically exported from code.google.com/p/timemap
MIT License
0 stars 0 forks source link

Make TimeMap.init() dataset types pluggable #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Rather than including all of the supported dataset types in the
TimeMap.init() switch statement, it should be easier to plug in new parser
types. One thought about how to do this: Store loaders in an object
attribute of TimeMapDataset, e.g.

TimeMapDataset.loaders = {
  // start with basic loader
  basic: TimeMapDataset.basicLoader
}

Each loader function would take an object parameter "options", including
data, dataset, preload and transform functions, and the LoadMgr object (or
just the ifLoaded function?). Then each file that defined a new parser
would also define the loader, adding it to the TMD.loaders object.

So instead of the switch statement, we'd just have 

loader = TimeMapDataset.loaders[data.type];
loader(options);

This would decouple the loader logic from the init function, making it
easier to add new loaders.

Original issue reported on code.google.com by nick.rab...@gmail.com on 22 May 2009 at 11:14

GoogleCodeExporter commented 9 years ago
Added in trunk.

Original comment by nick.rab...@gmail.com on 26 May 2009 at 5:30