Package | org.spicefactory.parsley.context |
Class | public class ContextBuilder |
Inheritance | ContextBuilder Object |
A standard ContextBuilder can be created using the newBuilder
method:
ContextBuilder.newBuilder() .config(XmlConfig.forFile("logging.xml")) .config(FlexConfig.forClass(MyConfig)) .build();
If you need to specify more options than just the configuration artifacts, you must enter setup mode first:
var viewRoot:DisplayObject = ...; var parent:Context = ...; ContextBuilder.newSetup() .viewRoot(viewRoot) .parent(parent) .viewSettings().autoremoveComponents(false) .newBuilder() .config(XmlConfig.forFile("logging.xml")) .config(FlexConfig.forClass(MyConfig)) .build();
Method | Defined By | ||
---|---|---|---|
Builds and returns the final Context instance, applying all settings
specified for this builder. | ContextBuilder | ||
complete(handler:Function):ContextBuilder
Adds a callback to invoke when the Context created by this builder
finishes initialization. | ContextBuilder | ||
Adds a configuration processor to this builder. | ContextBuilder | ||
error(handler:Function):ContextBuilder
Adds a callback to invoke when Context creation aborts with an error. | ContextBuilder | ||
[static]
Creates a new ContextBuilder instance applying default settings. | ContextBuilder | ||
[static]
Creates a new setup instance that allows to specify custom
options for the ContextBuilder to be created. | ContextBuilder | ||
object(instance:Object, id:String = null):ContextBuilder
Adds an existing instance to the Context created by this builder. | ContextBuilder | ||
Returns the factory that can be used to programmatically create new
object definitions using the framework's configuration DSL. | ContextBuilder |
build | () | method |
public function build():Context
Builds and returns the final Context instance, applying all settings specified for this builder.
ReturnsContext — the final Context instance
|
complete | () | method |
public function complete(handler:Function):ContextBuilder
Adds a callback to invoke when the Context created by this builder finishes initialization. This may happen synchronously or asynchronously.
The handler function has to accept a parameter of type Context.
Parameters
handler:Function — a callback to invoke when the Context created by this builder
finishes initialization
|
ContextBuilder — this builder instance for method chaining
|
config | () | method |
public function config(processor:ConfigurationProcessor):ContextBuilder
Adds a configuration processor to this builder.
The builtin configuration mechanisms offer convenient shortuts to
create such a processor like FlexConfig.forClass(MyConfig)
or XmlConfig.forFile("config.xml")
.
Parameters
processor:ConfigurationProcessor — the processor to add
|
ContextBuilder — this builder instance for method chaining
|
error | () | method |
public function error(handler:Function):ContextBuilder
Adds a callback to invoke when Context creation aborts with an error. This may happen synchronously or asynchronously.
The handler function has to accept a parameter of type Object for
the cause of the failure. This is usually an instance of type Error
or ErrorEvent
.
Parameters
handler:Function — a callback to invoke when Context creation aborts with an error
|
ContextBuilder — this builder instance for method chaining
|
newBuilder | () | method |
public static function newBuilder():ContextBuilder
Creates a new ContextBuilder instance applying default settings.
In case you want to specify options like view root, custom scopes
or parent Contexts, use newSetup
instead.
ContextBuilder — a new ContextBuilder instance applying default settings
|
newSetup | () | method |
public static function newSetup():ContextBuilderSetup
Creates a new setup instance that allows to specify custom options for the ContextBuilder to be created.
ReturnsContextBuilderSetup — a new setup instance that allows to specify custom
options for the ContextBuilder to be created
|
object | () | method |
public function object(instance:Object, id:String = null):ContextBuilder
Adds an existing instance to the Context created by this builder.
The only way to apply framework features to the target instance
is metadata in this case. If you need other means of applying features
to an object, consider using the objectDefinition
method instead.
Parameters
instance:Object — the instance to add to the Context
| |
id:String (default = null ) — the optional id of the instance
|
ContextBuilder — this builder instance for method chaining
|
objectDefinition | () | method |
public function objectDefinition():ObjectDefinitionBuilderFactory
Returns the factory that can be used to programmatically create new
object definitions using the framework's configuration DSL.
This allows for more fine-grained control of the functionality that
should be applied to the target instance than using the simple shortcut of
the object
method, where all object configuration would need
to be done with metadata.
ObjectDefinitionBuilderFactory — the factory that can be used to programmatically create new object definitions
|