import { Composer } from "https://deno.land/x/grammy_menu@v1.3.0/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