Plugin init order issue I have a plugin, which is using another plugin. The issue is that, I am calling some other plugin information in the init function, and I do receive sometimes this error:

2018-11-07 11:44:57 [-][-][k91hcavi6st542afnhsvhdp61u][error][yii\base\ErrorException:8] yii\base\ErrorException: Trying to get property 'mobileDetectService' of non-object in /home/forge/plugins/releases/20181106223004/src/services/CacheService.php:193
Stack trace:
#0 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler-&gt;handleError(8, 'Trying to get p...', '/home/forge/plu...', 193)
#1 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(193): craft\web\ErrorHandler-&gt;handleError(8, 'Trying to get p...', '/home/forge/plu...', 193, Array)
#2 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(126): trendspublishing\craftplugin\services\CacheService-&gt;_generateUri('/hubs/bathroom')
#3 /home/forge/plugins/releases/20181106223004/src/Plugin.php(90): trendspublishing\craftplugin\services\CacheService-&gt;uriToFilePath('/hubs/bathroom')
#4 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/BaseObject.php(109): trendspublishing\craftplugin\Plugin-&gt;init()
#5 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/Module.php(158): yii\base\BaseObject-&gt;__construct(Array)
#6 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/base/Plugin.php(113): yii\base\Module-&gt;__construct('craftplugin', Object(craft\web\Application), Array)
#7 [internal function]: craft\base\Plugin-&gt;__construct('craftplugin', Object(craft\web\Application), Array)


This is the error in question:

$mobile_detect = MobileDetect::$plugin-&gt;mobileDetectService;


I am not able to replicate it, sometimes a simple database reload is helping sometimes not. So that's why I am only guessing, because I do invoke this call from the plugin init function, that's why the other plugin is not ready yet...
Any thought, best practice on this one?
What I do is I listen for the Plugins::EVENT_AFTER_LOAD_PLUGINS event, and then do my code that relies on other plugins being loaded:

    // Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
    Event::on(
        Plugins::class,
        Plugins::EVENT_AFTER_LOAD_PLUGINS,
        function () {
            // Do stuff only after all other plugins have loaded
        }
    );