nocobase/docs/en-US/development/life-cycle.md

42 lines
882 B
Markdown
Raw Normal View History

2022-11-06 00:52:53 +00:00
# Life cycle
2022-11-06 00:52:53 +00:00
## Lifecycle of applications
<img src="./index/app-flow.svg" style="max-width: 380px;" />
2022-11-06 00:52:53 +00:00
## Lifecycle of plugins
2022-11-06 00:52:53 +00:00
<img src="./index/pm-flow.svg" style="max-width: 600px;" />
2022-11-06 00:52:53 +00:00
## Lifecycle methods for plugins
```ts
import { InstallOptions, Plugin } from '@nocobase/server';
export class MyPlugin extends Plugin {
afterAdd() {
2022-11-06 00:52:53 +00:00
// After the plugin pm.add is registered. Mainly used to place the app.beforeLoad event.
beforeLoad() { }
beforeLoad() {
2022-11-06 00:52:53 +00:00
// Before all plugins are loaded. Generally used for registering classes and event listeners
}
async load() {
2022-11-06 00:52:53 +00:00
// Load configuration
}
async install(options?: InstallOptions) {
2022-11-06 00:52:53 +00:00
// Logic for installing
}
async afterEnable() {
2022-11-06 00:52:53 +00:00
// After activation
}
async afterDisable() {
2022-11-06 00:52:53 +00:00
// After disable
}
async remove() {
2022-11-06 00:52:53 +00:00
// Logic for removing
}
}
export default MyPlugin;
```