Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy_menu/deps.deno.ts>Composer#fork

Easily create interactive menus with grammY.
Go to Latest
method Composer.prototype.fork
import { Composer } from "https://deno.land/x/grammy_menu@v1.1.2/deps.deno.ts";

This is an advanced method of grammY.

Registers some middleware that runs concurrently to the executing middleware stack.

bot.use( ... ) // will run first
bot.fork( ... ) // will be started second, but run concurrently
bot.use( ... ) // will also be run second

In the first middleware, as soon as next's Promise resolves, both forks have completed.

Both the fork and the downstream middleware are awaited with Promise.all, so you will only be to catch up to one error (the one that is thrown first).

In opposite to the other middleware methods on composer, fork does not return simply return the composer connected to the main middleware stack. Instead, it returns the created composer of the fork connected to the middleware stack. This allows for the following pattern.

// Middleware will be run concurrently!
bot.fork().on('message', ctx => { ... })

Parameters

...middleware: Array<Middleware<C>>

The middleware to run concurrently