Methods of loading, success, error, warning, reset

Service download status is a service through which you can control class for the upper forms in the application, this class uses semantic to display different States of form.

The control is performed by specifying the appropriate method and class.

Methods:

  • loading - controls the loading of the page
  • success - displays successful execution of operations
  • error - controls the display of errors
  • warning -controls the display of warning
  • reset - removes the established class

Example usage

Submitted example for ember 3.x.

1.To add the service in app controller:

// app/controllers/application.js 
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default Controller.extend({
    appState: service(),
});

2.To register the state of the application in the template:


<div class="ui {{appState.state}} form">
{{outlet}}
</div>

3.To use the service in the controller (component):

// app/controllers/my-controller.js 
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default Controller.extend({
    appState: service(),
    actions: {
        load() {
        this.get('appState').loading();
        this.load().finally(() => {
            this.get('appState').reset();
            });
        },
    },
});

In this instance, is the control page load, on successful completion of which the service deletes your settings.

Переведено сервисом «Яндекс.Переводчик» http://translate.yandex.ru