Function Registry

The Function Registry allows a FEF developer to override or extend common events.

Overriding or extending an event using the function registry is generally quite rare; usually, there is a better alternative to accomplishing the same task.


Function Syntax
Override an Event
Facade.FunctionRegistry.register("<some function>",
   function(behaviorFn,args){
       //Add code to execute on <some action>
   }
);
Extend an Event
Facade.FunctionRegistry.register("<some function>",
   function(behaviorFn,args){
       //Add code to execute on <some action>

       //Continue with default behavior
       return behaviorFn.resume();
   }
);
Execute a function
var activity = //user defined activity
Facade.FunctionRegistry.execute("<some function>",
           { activity: activity }
);
Common Functions Include: "core.page.edit", "core.page.preview", "core.page.startingPage", "core.page.inEditMode", "core.page.onSaveSuccess", "core.page.onSaveError", "core.page.onTransitionError", "core.data.create", "core.data.clean", "core.data.save", "core.attachment.attach", "core.activityLog.onUIActivityComplete"
NOTE: Components such as buttons and popovers will have functions registered for them. To view all of the available functions on your FEF while in development, go into debug mode and put a breakpoint within the function-registry.js register method.

Register & Execute Custom Function

Let's say we want to run a method when a button is clicked. To do this, place your method into the FunctionRegistry and execute the function when your event occurs.

Facade.FunctionRegistry.Register("custom.onClick.Function", function(behaviorFn, args){
    //code to execute when this FunctionRegistry is executed
});

var myBtn = Facade.Components.Button.forName("functionExample");
myBtn.setOnClick( function(behaviorFn,args){
    Facade.FunctionRegistry.execute("custom.onClick.Function");
    return behaviorFn.resume();
});