Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4869

Best Practices - Coalescing app configs and addon configs

$
0
0

I’m building an addon that’s mostly UI blocks. From the dummy app, I’ve validated “everything works.”

Within the dummy app, I want to show different layout options (css styles for minifiedNav or fullWidthContainer vs fixedWidthContainer, etc.) so I’ve created a “Settings” service to handle state. It’s working just as I want it to at the moment.

The next thing I can’t figure out is how to connect application environment configs to my service to prepopulate the app owner’s intention.

All the documentation I can find is from the app’s perspective (Configuring Your App - Configuration - Ember Guides for example) and includes the app’s name which doesn’t work here (my addon name doesn’t work either).

I have a strange solution that works:

export default class SettingsService extends Service {
  @tracked appLayout = {
    @tracked fixedHeader: false,
    @tracked fixedNavigation: false,
    @tracked minifyNavigation: false,
    @tracked hideNavigation: false,
    @tracked topNavigation: false,
    @tracked darkMode: false,
    @tracked boxedLayout: false,
  };
  constructor(app){
    super(app);
    deepmerge(this, app.application.Firewater);
  }
}

But it feels like I have a Rube Goldberg mess of an operation I’d expect many Addon Developers want to do… I just can’t find the documentation! Any pointers?

7 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 4869

Trending Articles