lundi 22 mai 2017

The proper way to store/load statics in Ember App

currently I'm thinking of the way to load statics into my Ember app. The problem:

I have app branded logo, app name, app title (browser tab label), texts for routes etc. What I'm doing now is the following:

 model() {
   let defaultHeaderModel = {
   logo: '/img/logo-cloud.svg',
   brand: {
     name: 'CloudCenter',
     logo: '/img/logo-cloud.svg'
   },
   userLinks: [{
     text: 'Logout',
     route: 'logout'
   }],
   navigation: [{
     text: 'Login',
     route: 'login'
   }]
 };
}

As you can see all of the values are hardcoded. What I'd like to do is to somehow load that "statics" and use them through some variables. For ex: header.logo = resources.logo. My thoughts:

1) Use environment - store all of that values in the config.js and import it where needed. Cons: not sure if that data belongs to environment

2) ES6 POJO which can be imported to the app.

3) .json and some staticsService which will load .json file and through it I will have access to that values.

Are there any standardized approach to do such things? Or maybe better suggestions?




Aucun commentaire:

Enregistrer un commentaire