jeudi 28 septembre 2017

How to always load an ember-engines with Ember.JS

I am currently trying to access my ember-engines wherever I am. I want to have the name of each engines, because I want to display every engines in my main application.
The problem here is that I can't find a way to catch there name, because the engines are loaded only if we navigate to a page related to the engines.
This is the services that is normally catching every name of each engines, call it engines-manager:

import Ember from 'ember';
import App from '../app';

/**
 * This service will help us manage every engines that are in our application,
 */

export default Ember.Service.extend({
    availableEngines: [],

    addEngines(engines)
    {
        this.get('availableEngines').push(engines);
        console.log(this.get('availableEngines'));
    }
});

And then in every engine, more precisely, in every anEngines/addon/engine.js of every engine, I put :

import Engine from 'ember-engines/engine';
import loadInitializers from 'ember-load-initializers';
import Resolver from './resolver';
import config from './config/environment';
import Ember from 'ember';

const { modulePrefix } = config;

const Eng = Engine.extend({
    modulePrefix,
    Resolver,
    dependencies: {
        services: [
            'engines-manager'
        ]
    },
    enginesManager: Ember.inject.service('engines-manager'),
    init() {
        this._super(...arguments);
        this.get('enginesManager').addEngines('nameOfMyEngines');
    }
});

loadInitializers(Eng, modulePrefix);

export default Eng;

This method is working if we go on the engines related page, but I dont want to go to every page to load them, so here is my question: how to always load an ember-engines?

PS: setting my lazy-loading to trueor false doesn't change anything.




Aucun commentaire:

Enregistrer un commentaire