MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / onLifecycle

Method onLifecycle

src/api/TaskNotesAPI.ts:2567–2599  ·  view source on GitHub ↗
(
		event: EventName,
		handler: TaskNotesRuntimeLifecycleHandler<EventName>
	)

Source from the content-addressed store, hash-verified

2565 }
2566
2567 onLifecycle<EventName extends TaskNotesRuntimeLifecycleEventName>(
2568 event: EventName,
2569 handler: TaskNotesRuntimeLifecycleHandler<EventName>
2570 ): EventRef {
2571 const rawEvent = TASKNOTES_RUNTIME_LIFECYCLE_RAW_EVENTS[event];
2572 const ref = this.plugin.emitter.on(rawEvent, (payload: unknown) => {
2573 handler(
2574 this.normalizeLifecycleEvent(
2575 event,
2576 rawEvent,
2577 payload
2578 ) as TaskNotesRuntimeLifecyclePayload & {
2579 event: EventName;
2580 }
2581 );
2582 });
2583
2584 if (event === "ready") {
2585 void this.plugin.onReady().then(() => {
2586 handler(
2587 this.normalizeLifecycleEvent(
2588 event,
2589 rawEvent,
2590 undefined
2591 ) as TaskNotesRuntimeLifecyclePayload & {
2592 event: EventName;
2593 }
2594 );
2595 });
2596 }
2597
2598 return ref;
2599 }
2600
2601 emitLifecycle(
2602 event: TaskNotesRuntimeLifecycleEventName,

Callers 1

TaskNotesAPIClass · 0.95

Calls 4

onReadyMethod · 0.80
onMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected