cancel
Showing results for 
Search instead for 
Did you mean: 

Aikau Widget Function Signatures

stuartonmaui
Champ in-the-making
Champ in-the-making
Many Aikau Widgets (such as DateTextBox, form controls) seem to use the following:

define(["alfresco/core/Core",
       …
    ],
    function(declare, _Widget, Core, _Templated, template) {   
      return declare([_Widget, Core, _Templated], {



But others have different ones. For example, alfresco/html/Image calls for

define([….],
        function(urlTypes, Image, declare, domClass) {
        return declare([Image], {

Looking at the code for such widgets does not seem to reveal the required signature. For these widgets, lacking an example, how should I determine the proper definition?
1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator
I am not sure I understand the question. The functions given as examples are not constructors of widget instances - they are merely the module definition and factory functions that are used to define and initialise the module within the module system. Those are never directly called by any client code that you write based on Aikau. Their signature depends on the list of dependencies they need to pull in and the set of base modules / classes they need for defining their specific module / class via declare.

The signature for any widget constructor in Aikau is always the same - it is 'function(params)' where params is a simple object / hash of all the configuration properties you want to set on the widget.

But generally speaking you should also (almost) never call a widget constructor directly. Widget construction can be delegated to functions from Aikau mixins such as CoreWidgetProcessing#processWidgets (or #createWidget). This ensures widgets are instantiated uniformly and avoids any issues with you forgetting to include a common parameter / property.

Regards
Axel