K
K
kartio2015-05-08 18:30:23
Ember.js
kartio, 2015-05-08 18:30:23

What is the best way to organize the loading of application metadata?

All application settings are stored on the server, these are roles, available routes filtered by roles, menu settings, panel settings, filter settings for the current user for grids.
All this is easiest to get from the server with one json object, access to this data is needed from all parts of the application.
What is the best way to arrange this? Because it somehow does not fall on the ember-data models. Set up as a service? But how to load all this before loading the application itself in synchronous mode, because all parts of the application should work on the basis of this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Romanov, 2015-05-08
@Kaer_Morchen

It's strange that you can't rely on ember-data models, but how do you store them if not in the database?
As an option, add the configs field to user in which you store all the necessary settings. In a database, this field can be text/json as a last resort.
You can get the necessary data before initializing the application through the initializer

Ember.Application.initializer({
    name: 'appBootstrap',
    initialize: function(container, app) {
        app.deferReadiness(); //Останавливаем инициализацию

       Ember.$.ajax("urlToData").then(function(data) {
                //Делаем нужные дела с data
                //Положить данные в store можно так
                var store = container.lookup('store:main');
                store.pushPayload('data', data);

                app.advanceReadiness(); //Продолжаем загрузку
       });
    }
});

I use ember-simple-auth in my applications . I get access to the settings through session.user.configs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question