Skip to content

vocalime-base/jovo-standard-events-plugin

Repository files navigation

Welcome to Jovo Standard Events Plugin 👋

Version License: MIT Workflow

Handle standard events outside your components.

Install

npm install @vocalime/jovo-standard-events-plugin

Example

index.js

import { StandardEventPlugin } from '@vocalime/jovo-standard-events-plugin';
import { App } from '@jovotech/framework';
import {
    newUser,
    newSession,
    onRequest,
    onResponse,
} from './standard-event-handlers';

export const app = new App({
    components: [
        // Your components
    ],
    plugins: [
        // Other plugins...,
        new StandardEventsPlugin({
            newUserHandlers: [newUser],
            newSessionHandlers: [newSession],
            onRequestHandlers: [onRequest],
            onResponseHandlers: [onResponse],
        }),
    ],
});

standard-event-handlers.ts

import { Jovo } from '@jovotech/framework';

export async function newUser(jovo: Jovo): Promise<void> {
    console.log('This function runs the first time the user invokes your app.');
}

export async function newSession(jovo: Jovo): Promise<void> {
    console.log('This function runs once per session.');
}

export async function onRequest(jovo: Jovo): Promise<void> {
    console.log('This function runs once per request after deserializing the request from JSON.');
}

export async function onResponse(jovo: Jovo): Promise<void> {
    console.log('This function runs once per request before serializing the response to JSON.');
}

Author

👤 Vocalime

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 vocalime.

This project is MIT licensed.