node-red/node-red — pull request #289 by zobalogh (2014-07-23 14:29:08+00:00)
Title: DO NOT MERGE YET: Re-structuring storage init.

Hi Nick, this is a pull request to show you what I think is a possible way of re-wiring the storage/index.js so that it's more like an interface. I'm interested in your thoughts on it.

Please check if I'm going down on the right path. Also, where do I want to call moduleSelector(settings); from?

I'm not sure if I can call it from storageModuleInterface I defined unless I pre-define some kind of dummy object for storageModule.

Alternate ideas:

We could also possibly (although I don't know enough about JavaScript yet to see if this actually makes sense):

var storageModuleInterface = {
init : function(_settings) {
moduleSelector(settings);
return storageModule.init(_settings);
}
...........
}

storageModuleInterface.init();
module.exports = storageModuleInterface;

Or alternatively, a somewhat simpler model, but one that changes the existing external interface:

......
init : function(_settings) {
moduleSelector(_settings);
return storageModule.init(_settings);
}
......
Thanks!