attachEmailHandler function

void attachEmailHandler(
  1. CloudflareWorkersEmailEvent handler
)

Implementation

void attachEmailHandler(CloudflareWorkersEmailEvent handler) {
  globalDartEmailHandler = allowInterop((interop.EmailMessage message,
      interop.Environment env, interop.ExecutionContext ctx) {
    return futureToPromise(Future(() async {
      return handler(
        emailMessageFromJsObject(message),
        environmentFromJsObject(env),
        executionContextFromJsObject(ctx),
      );
    }));
  });
}