Correct instructions for AppLifecycleListener

This commit is contained in:
Dmitry Jemerov 2020-01-02 12:28:06 +01:00
parent 1826d086e6
commit d26ee46bca

View File

@ -19,8 +19,7 @@ To migrate your code from components to more modern APIs, please use the followi
and implement the `PersistentStateComponent` interface. See [Persisting State of Components](/basics/persisting_state_of_components.md) for details. and implement the `PersistentStateComponent` interface. See [Persisting State of Components](/basics/persisting_state_of_components.md) for details.
* To subscribe to events, use a [listener](plugin_listeners.md) or create an [extension](plugin_extensions.md) for a dedicated extension point (for example, `com.intellij.editorFactoryListener`) if one exists for the event you need to subscribe to. * To subscribe to events, use a [listener](plugin_listeners.md) or create an [extension](plugin_extensions.md) for a dedicated extension point (for example, `com.intellij.editorFactoryListener`) if one exists for the event you need to subscribe to.
* Executing code on application startup should be avoided whenever possible because it slows down startup. * Executing code on application startup should be avoided whenever possible because it slows down startup.
Plugin code should only be executed when projects are opened or when the user invokes an action of your plugin. If you can't avoid this, create Plugin code should only be executed when projects are opened or when the user invokes an action of your plugin. If you can't avoid this, add a [listener](plugin_listeners.md) subscribing to the [AppLifecycleListener](upsource:///platform/platform-impl/src/com/intellij/ide/AppLifecycleListener.java) topic.
an [extension](plugin_extensions.md) for the `com.intellij.appLifecycleListener` extension point.
* To execute code when a project is being opened, provide [StartupActivity](upsource:///platform/core-api/src/com/intellij/openapi/startup/StartupActivity.java) implementation and register an [extension](plugin_extensions.md) for the `com.intellij.postStartupActivity` or `com.intellij.backgroundPostStartupActivity` extension point (the latter is supported starting with version 2019.3 of the platform). * To execute code when a project is being opened, provide [StartupActivity](upsource:///platform/core-api/src/com/intellij/openapi/startup/StartupActivity.java) implementation and register an [extension](plugin_extensions.md) for the `com.intellij.postStartupActivity` or `com.intellij.backgroundPostStartupActivity` extension point (the latter is supported starting with version 2019.3 of the platform).
* To execute code on project closing or application shutdown, implement the `Disposable` interface in a [Service](plugin_services.md) * To execute code on project closing or application shutdown, implement the `Disposable` interface in a [Service](plugin_services.md)
and place the code in the `dispose()` method, or use `Disposer.register()` passing a `Project` or `Application` instance and place the code in the `dispose()` method, or use `Disposer.register()` passing a `Project` or `Application` instance