Access a provider through other provider (advice)

Hi,
I’d like to be adviced by you (experienced) devs if it’s okay to acces a provider through an other provider.

Example use case:
I have a settingsprovider which keeps track of the global app settings like (can) vibrate for example.

settingsprovider  ->
   public notifications['vibrate'] = true; 

Then I also have a function in the notificationprovider which I use for executing a notification like vibrating.

notificationprovider  ->   
 import { SettingsProvider } from 'XXX';
 // some code ..
 vibrate(time: number = 300) {
    if (true === this.settingsProvider.notifications['vibrate']) {
      this.vibration.vibrate(time);
    }
  }

Every time when the app needs to vibrate the notificationprovider checks the setting in the settingsprovider.
So for I think it’s okay to use it like this? If there’s a better way of implementing this feel free to advice.

Then the actual question:
Let’s say, when I’m in the in the SettingsPage and I only have declared the notificationprovider in the constructor. Is it okay to access the settingsprovider for changing 1 single setting value through the notificationprovider? (I know it doesn’t make sense not to import a settingsprovider to the class of the settings page, just giving it as an example.)

//so in the SettingsPage class I would like to try something like:
  myButtonClick(){
    this.notificationProvider.settingsProvider.notifications['vibrate'] = true;
    this.notificationProvider.vibrate();
  }

Why I would want to know this?

  • I just want to change 1 thing in the other provider, why would I import a whoooolee provider for just changing 1 variable.
  • (in general) Does it effect the performance of an app (in the bad way) when I DO import a provider over and over and over. Or would accessing a provider through a provider be more harmfull for my app.
  • And how about a ‘main’ provider importing all providers, and then access any provider through that one main provider so I only would need to import that main provider in my pages.

And again, I know some things don’t make sense to do so, and sure there would be some exceptions, but I just want some feedback from different points of views on this to create a nice way of designing an app structure.

I hope I made myself clear with my question. Thank you for your time and answers.

Anyone having some thoughts on this?