The following describes the entry points that a Synchro module may export. Most functions exported from a Synchro module share the following parameters:

  • context - An opaque context object that should only be used for passing to other API entrypoints that require it.
  • session - The current session.
  • viewModel - The current viewModel object.


exports.View = { ... };

The View is an object representing the view template for the module.


exports.InitializeView(context, session, viewModel, view, metrics, isViewMetricUpdate)

The InitializeView entrypoint is optional. The view is typically provided by the exported View object, but this entrypoint can be implemented if you desire to either modify that View, or generate your own view, from code. Any View defined by the exported View object will be passed to this function (if no View object was exported, that value will be undefined).

This entrypoint, if present, is called both on rendering of the initial view template, and whenever the ViewMetrics change (such as when the orientation of the device or viewport of the app changes). The isViewMetricUpdate boolean parameter to this function signals why the entrypoint was called.


exports.InitializeViewModel(context, session, params, state)

The InitializeViewModel entrypoint is required. It must generate and return the initial view model object.


exports.LoadViewModel(context, session, viewModel)

The LoadViewModel entrypoint is optional. It is used if there is additional processing required on the initial view model after it has been generated by InitializeViewModel and passed to the client.


exports.OnViewMetricsChange(context, session, viewModel, metrics)

The OnViewMetricsChange entrypoint is optional. It is called when the view metrics change, such as when the orentation changes, or when the application viewport size changes.


exports.OnViewModelChange(context, session, viewModel, source, changes)

The OnViewModelChange entrypoint is optional. It is called when the view model has been changed, either by the client or by the server. The source parameter indicates wether the change was generated by the client or the server.


exports.OnBack(context, session, viewModel)

The OnBack entrypoint is optional. If it is present, it is called when the user triggers the back mechanism on their device (either in the app command bar, via a hard back button, or using some other platform-defined behavior).

If the navigation action is performed inside of OnBack, then it should return true. If OnBack is implemented and does not return true, the default back navigation action, Synchro.pop(), will be performed.


Commands is a dictionary of user-defined entrypoints that may be called from various controls which bind to them.

exports.Commands =
    sampleCmd: function(context, session,  viewModel, params)