Skip to content

Commit 00548d8

Browse files
committed
Improve example one more time
1 parent a7a75be commit 00548d8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

docusaurus/docs/cms/configurations/functions.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ All 3 lifecycle functions can be put together to configure custom behavior durin
446446
3. Restart Strapi to confirm each lifecycle executes in sequence.
447447

448448
```ts title="src/index.ts"
449-
let unsubscribeCreate: (() => void) | undefined;
449+
let cronJobKey: string | undefined;
450450

451451
export default {
452452
register({ strapi }) {
@@ -458,13 +458,22 @@ export default {
458458
},
459459

460460
async bootstrap({ strapi }) {
461-
unsubscribeCreate = strapi.eventHub.subscribe('entry.create', (event) => {
462-
strapi.log.info(`New entry created in ${event.model}: ${event.result?.id}`);
461+
cronJobKey = 'log-reminders';
462+
463+
strapi.cron.add({
464+
[cronJobKey]: {
465+
rule: '0 */6 * * *', // every 6 hours
466+
job: async () => {
467+
strapi.log.info('Remember to review new content in the admin panel.');
468+
},
469+
},
463470
});
464471
},
465472

466-
async destroy() {
467-
unsubscribeCreate?.();
473+
async destroy({ strapi }) {
474+
if (cronJobKey) {
475+
strapi.cron.remove(cronJobKey);
476+
}
468477
},
469478
};
470479
```

0 commit comments

Comments
 (0)