function main
thefrontside/effectionasync function main(body: (args: string[]) => Operation<void>): Promise<void>
Top-level entry point to programs written in Effection. That means that your
program should only call main once, and everything the program does is
handled from within main including an orderly shutdown. Unlike run, main
automatically prints errors that occurred to the console.
Use the exit operation form within to halt program execution immediately and initiate shutdown.
The behavior of main is slightly different depending on the environment it
is running in.
Deno, Node
When running within Deno or Node, any error which reaches main causes the
entire process to exit with an exit code of 1.
Additionally, handlers for SIGINT are attached to the
process, so that sending an exit signal to it causes the main task
to become halted. This means that hitting CTRL-C on an Effection program
using main will cause an orderly shutdown and run all cleanup code.
Warning! do not call
Deno.exit()on Deno orprocess.exit()on Node directly, as this will not gracefully shutdown. Instead, use the exit operation.
Browser
When running in a browser, The main operation gets shut down on the
unload event.
Parameters
body: (args: string[]) => Operation<void>
- an operation to run as the body of the program
Return Type
Promise<void>
a promise that resolves right after the program exits