Skip to content

RL2 ContextBuilder #32

Closed
darscan opened this Issue Oct 29, 2011 · 7 comments

4 participants

@darscan
Robotlegs member
darscan commented Oct 29, 2011

An issue to discuss to discuss the Context Builder API and implementation.

@darscan darscan was assigned Oct 29, 2011
@joelhooks
Robotlegs member

What is outstanding in terms of the CB?

@robertpenner
Robotlegs member

public interface IContextBuilderBundle
{
function install(builder:IContextBuilder):void;
}

public interface IContextConfig
{
function configure(context:IContext):void;
}

public interface IContextExtension
{
function install(context:IContext):void;
function initialize():void;
function uninstall():void;
}

I am finding it less than obvious what belongs in a bundle vs. a config vs. an extension. And the ContextBuilder code for managing these 3 things has some duplication. Also, ConfigManager and ExtensionManager have some duplication and feel a bit like busywork.

I have a naive thought that some of these could be replaced with prescriptive commands with [Inject] points and an interface that indicates the thing can be installed/uninstalled. I hope we can reduce the number of concepts and types a bit. Just a gut thing; could be wrong.

@darscan
Robotlegs member
darscan commented Jan 4, 2012

IContextConfig, IContextBuilderBundle, IContextExtension, ExtensionManager etc, are monsters and I apologise for their existence. They are the shameful remnants of one of my failed attempts at solving a couple of problems.

Essentially, extensions and bundles need a way to hook in to the builder/context life-cycles in order to configure things at different stages of the build process.

Sometimes these extensions only need to know when the builder/context entered into a specific phase.

For example, an extension that simply wants to put a mapping into the injector must, at the very least, wait for an injector to be available and finalised before it can safely do.

An extension that depends on services offered by another extension can only configure itself when those services have been made available (mapped into the injector).

And there are times when an extension needs to be able to suspend the build at a particular point and wait for a file or module to load, or some other asynchronous process to complete.

The lolcode presently residing in my portion the repo attempts to offer this functionality by providing interfaces that the builder/"extension manager" can call into at various stages of the build. It is absolutely, stunningly horrendous. At the time I just wanted something smallish that didn't require metadata processing or a flow control library, and wouldn't force us into building an object definition registry. I was trying to keep it small, but just made a mess - although it did give a better feel for the problem. I'm trying out a new approach tonight/tomorrow, will see how that goes. The new approach is not at all directly related to any of these async JavaScript libraries:

Promises/A spec

http://wiki.commonjs.org/wiki/Promises/A

task.js (Promise/A)
http://taskjs.org/
https://github.com/mozilla/task.js/blob/master/lib/task.js

jQuery Deferred (Promise/A)
http://api.jquery.com/category/deferred-object/
https://github.com/jquery/jquery/blob/master/src/deferred.js
https://github.com/jquery/jquery/blob/master/test/unit/deferred.js

async
https://github.com/caolan/async
https://github.com/caolan/async/blob/master/test/test-async.js

when.js
https://github.com/briancavalier/when.js
https://github.com/briancavalier/when.js/blob/master/when.js

@joelhooks
Robotlegs member

I mentioned in our other discussion http://disq.us/4tyhr6 that I like the current approach. What I like is using command like objects In the Builder to configure my Context.

@Stray
Robotlegs member
Stray commented Jan 4, 2012
@darscan
Robotlegs member
darscan commented Jan 4, 2012

Indeed, the main thing was just to get the rough shape of the framework in place.

@darscan
Robotlegs member
darscan commented Jan 25, 2012

My new approach is in place and feels fairly resolved. Closing this for now, feel free to re-open.

@darscan darscan closed this Jan 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.