Adding plugins post initial load

I have a case where I need to add my plugins post initial load. The way my team implemented OIDC has us doing a lot of unnecessary plugin loading when the site will be simply redirected to the login page. It is only after a user is available from OIDC when I want to load the rest of the plugins.

I have tried to add the plugins by instantiating a new FrameworkConfiguration(this.aurelia) where this.aurelia is injected at the constructor. I add the plugins then call config.apply ();

this does not work. I get the this config instance has already been applied. To load more global resources, create a new FrameworkConfiguration instance.

1 Like

Can you clarify if you are injecting Aurelia, or are you injecting something else?

The class that I am trying new new up the FrameworkConfiguration has Aurelia being injected into the constructor.

Can you give some pseudo code? From what i understand, simply the follow could already do:

export class MyEl {
  static inject = [Aurelia]

  constructor(aurelia) {
    const config = new FrameworkConfiguration(aurelia);
    config.use.....
    config.apply();
  }
}
1 Like

That is effectively what I’m doing, except I’m using autoinject with typescript and the new config occurs in a function that I call when needed.

1 Like

Are there any known issues with this? It’s another poorly documented feature.

There shouldnt be any. Though its an async process, so best done in router viewport componr ts, during activate/configureRouter cycle. And probably need to make sure its applied only once, regardless how many times a component is activated. Sorry aboit the doc though, could you help with that :blush:

I’m going to have to make a simple test application.

I’m not relying on component life cycle, I want to only load these plugins if some some condition is met and the loading occurs in a service class.

1 Like