Tutorials

Classes

App
Core/Context
StatusCodes
LastState
Data/Bean
Data/BeanCollection
Data/MixedBeanCollection
Validators
Utils/Date
duration
Cookie
View/AlertView
View/Component
View/Field
View/Layout
View/View

Mixins

Core/BeforeEvent
Utils/UnderscoreMixins

Events


app:init

Fires when the app object is initialized. Modules bound to this event will initialize.


app:locale:change

Fires when client application's user changes the locale, thus indicating that the application should "re-render" itself.


app:login

  • Fires when logging in.

app:login:success

Fires when login succeeds.


app:logout

Fires when the app logs out.


app:start

Fires when the application has finished loading its dependencies and should initialize everything.


app:sync

Fires when the app is beginning to sync data / metadata from the server.


app:sync:complete

Fires when the app has finished its syncing process and is ready to proceed.


app:sync:error

Fires when a sync process failed.


app:sync:public:error

Fires when a sync process failed during initialization of the app.


app:view:change

Fires when route changes a new view has been loaded.


lang:direction:change

Fires when the language display direction changes.

Possible language display directions are RTL and LTR.


reload

Triggered before and after the context is reloaded.

Parameters:
Name Type Argument Description
this Core/Context

The context instance where the event is triggered.

options Object <optional>

The options passed during Core/Context#reloadData call.


data:sync:abort

Fires on model when the sync operation ends.

Three parameters are passed to the callback:

  • operation name (method)
  • options
  • request SUGAR.Api.HttpRequest
model.on('data:sync:abort', function(method, options, request) {
    SUGAR.App.logger.debug('Operation aborted ' + method + ' on ' + model);
});

data:sync:abort

Fires when the sync operation was aborted.

Four parameters are passed to the callback:

  • operation name (method)
  • reference to the model/collection
  • options
  • request SUGAR.Api.HttpRequest
const Events = require('core/events');
SUGAR.App.events.on('data:sync:abort', function(method, model, options, request) {
    SUGAR.App.logger.debug('Operation aborted ' + method + ' on ' + model);
});

data:sync:complete

Fires on model when the sync operation ends.

Three parameters are passed to the callback:

  • operation name (method)
  • options
  • request SUGAR.Api.HttpRequest
model.on('data:sync:complete', function(method, options, request) {
    SUGAR.App.logger.debug('Finished operation ' + method + ' on ' + model);
});

data:sync:complete

Fires when the sync operation ends.

Four parameters are passed to the callback:

  • operation name (method)
  • reference to the model/collection
  • options
  • request (SUGAR.Api.HttpRequest)
const Events = require('core/events');
Events.on('data:sync:complete', function(method, model, options, request) {
    SUGAR.App.logger.debug("Finished operation " + method + " on " + model);
});

data:sync:error

Fires on model when the sync operation ends unsuccessfully.

Three parameters are passed to the callback:

  • operation name (method)
  • options
  • error SUGAR.Api.HttpError
model.on('data:sync:error', function(method, options, error) {
    SUGAR.App.logger.debug('Operation failed:' + method + ' on ' + model);
});

data:sync:error

Fires when the sync operation ends unsuccessfully.

Four parameters are passed to the callback:

  • operation name (method)
  • reference to the model/collection
  • options
  • error (SUGAR.Api.HttpError)
const Events = require('core/events');
Events.on('data:sync:error', function(method, model, options, error) {
    SUGAR.App.logger.debug('Operation failed ' + method + ' on ' + model);
});

data:sync:start

Fires when the sync operation starts.

Three parameters are passed to the callback:

  • operation name (method)
  • reference to the model/collection
  • options
const Events = require('core/events');
Events.on('data:sync:start', function(method, model, options) {
    SUGAR.App.logger.debug('Started operation ' + method + ' on ' + model);
});

data:sync:start

Fires on model when the sync operation starts.

Two parameters are passed to the callback:

  • operation name (method)
  • options
model.on('data:sync:start', function(method, options) {
    SUGAR.App.logger.debug('Started operation ' + method + ' on ' + model);
});

data:sync:success

Fires when the sync operation ends successfully.

Four parameters are passed to the callback:

  • operation name (method)
  • reference to the model/collection
  • options
  • request (SUGAR.Api.HttpRequest)
const Events = require('core/events');
Events.on('data:sync:success', function(method, model, options, request) {
    SUGAR.App.logger.debug('Finished operation ' + method + ' on ' + model);
});