fluid.demands()
{section}
{column:width=70%}
Registers a specification for resolving the invocation of a particular function name in a given context.
{code:javascript|borderStyle=none|bgColor=white} Section |
---|
Column |
---|
| Registers a specification for resolving the invocation of a particular function name in a given context. Code Block |
---|
| javascript |
---|
bgColor | white |
---|
borderStyle | none |
---|
| javascript |
---|
|
fluid.demands(functionName, context, demandsSpec/argsArray);
|
|
| {code}
* * {{}}
h2. Parameters
{span:class=borderless-table}
| {{{*}functionName{*}}} | (String) the name of the function demand which this specification matches. |
| {{{*}context{*}}} | (String or Array of Strings) the name(s) of the context(s) in which this demand specification applies. See [#Contexts] below for more information. |
| {{{*}demandsSpec/argsArray{*}}} | Parameters Span |
---|
| functionName | (String) the name of the function demand which this specification matches. | context | (String or Array of Strings) the name(s) of the context(s) in which this demand specification applies. See #Contexts below for more information. | demandsSpec/argsArray | (Object)/(Array) |
|
|
| [ Specification] |
{span}
h2. Return Value
{span:class=borderless-table}
| *None* | |
{span}
{column}
{column:width=5%}
{column}
{column}
h3. See Also
* [fluid.initDependents]
* [fluid.defaults]
* [Demands Specifications]
* [API]
{column}
{section}
----
h3. Notes
h4. Contexts
{excerpt-include:Contexts|nopanel=true} The {{context}} parameter to {{fluid.demands}} specifies a name for particular context in which the supplied demands are intended to be valid.
For more detailed information about contexts, see [Contexts].
h4. Demands Specification
The third parameter to {{fluid.demands()}}, {{{*}spec{*}}}, is the demands specification that declares how the function invocation is to be disposed, in the case that the overall block matches. This parameter can take one of several possible forms:
{span:class=borderless-table}
| {code:javascript} NotesContexts Insert excerpt |
---|
| Contexts |
---|
nopanel | true |
---|
| Contexts |
---|
| The context parameter to fluid.demands specifies a name for particular context in which the supplied demands are intended to be valid.For more detailed information about contexts, see Contexts. Demands SpecificationThe third parameter to fluid.demands() , spec , is the demands specification that declares how the function invocation is to be disposed, in the case that the overall block matches. This parameter can take one of several possible forms: Span |
---|
| Code Block |
---|
|
{
funcName: "functionName",
args: [array of arguments]
}
|
|
| {code} | The array of arguments can contain references to any | The array of arguments can contain references to any value-resolved |
| {{}} blocks |
{span}
h3. Example
{code:javascript}Example Code Block |
---|
|
fluid.demands(
"my.component",
"my.application",
{
funcName: "my.componentImpl",
args: ["{application}.model", "{application}.options.strings"],
});
| {code}
In this example, the component {{my.component }} is specifying its requirements when used in the context of {{my.application }}. The request is that the component be instantiated using a function called {{my.componentImpl }}, passed the {{args }} array as a parameter.
When the IoC system fulfills the demands, the {{model }} property and the {{options.strings }} property of the {{my.application }} object will be retrieved and inserted in the {{args }} array before the function is called.
{div} |