Child pages
  • Expansion of Component Options

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning

This page is still being drafted; some of it may, in fact, be incorrect.

Expanders

Infusion component option defaults now go through a process called "expansion" during the component creation process. An expander is essentially a function that is called at component-creation time to create the value of the default. This can be useful when static definition of a default option is not possible.

...

Two expanders are currently provided by the framework, and component creators can specify these expanders in their default options:

deferredCall

...

fluid.

...

deferredCall

...

The fluid.deferredCall

...

This expander will call the specified function, passing it the arguments provided. The return value will be assigned to the default option. For example:

Section
Column
Code Block
javascript
javascript
fluid.defaults("cspace.search.searchView", {
    components: {
        resultsPager: {
            type: "fluid.pager",
            options: {
                modelFilter: {
                    expander: {
                        type: "fluid.deferredCall",
                        func: "cspace.search.makeModelFilter",
                        args: ["{searchView}"]
                    }
                }
            }
        }
   }
});
Column

In this example, the resultsPager is specified as an instance of the Infusion Pager component. When this subcomponent is created, the deferredCall expander will call the function cspace.search.makeModelFilter, passing it the parent searchView component as an argument. The return value will be used as the default modelFilter option to the Pager.

fluid.deferredInvokeCall

...

The fluid.deferredInvokeCall

...

This expander is essentially the same as fluid.deferredCall, but this it will actually perform resolution of the client's demanded name. That is, it will look up the function name in the registered demands to determine what function will actually be called. For example:

...