locator icon indicating copy to clipboard operation
locator copied to clipboard

locatorObj.ready could be a promise fulfilled after parseBundle() is done

Open caridy opened this issue 10 years ago • 5 comments

// locator initialization
var locator = new Locator({
    buildDirectory: 'build'
});

locator.plug(pluginOne())
   .plug(pluginTwo())
   .plug(pluginThree())
   .parseBundle(__dirname, {});

locator.ready.then(function(have) {
    // do something...
});

this will facilitate passing locator instance around into different components that requires filesystem abstraction and let them know when locator is ready to be used.

related to modown trello card 203

caridy avatar Sep 12 '13 13:09 caridy

I will also argue that the __dirname passed into parseBundle should be a property of the instance since we don't expect parseBundle to be called twice for a locator instance.

caridy avatar Sep 12 '13 13:09 caridy

locatorObj.parseBundle() already returns the then. is a getter needed?

// current api
var locator = new Locator({
    buildDirectory: 'build'
});

var ready = locator.plug(pluginOne())
   .plug(pluginTwo())
   .plug(pluginThree())
   .parseBundle(__dirname, {});

// the "then" function
ready(function(have) {
    // do something...
});

isao avatar Sep 12 '13 20:09 isao

Early on while developing the locator we were uncertain if parseBundle() would be called multiple times. Since now it's not intended to be, and instead is intended to be called once at the "root" directory it should perhaps be called parseAppRoot() or parseRootBundle().

drewfish avatar Sep 12 '13 21:09 drewfish

@drewfish that sounds good (or maybe just parse, or exec, or something). also moving options from the parse method to the constructor where it makes sense, and making available some metadata available as @caridy suggests

isao avatar Sep 12 '13 21:09 isao

when can we get this rolling?

caridy avatar Sep 16 '13 17:09 caridy