mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
F: add wait until
This commit is contained in:
parent
48810b52f6
commit
cfb05f8e3b
18
cloudflare/context.go
Normal file
18
cloudflare/context.go
Normal file
@ -0,0 +1,18 @@
|
||||
package cloudflare
|
||||
|
||||
import (
|
||||
"context"
|
||||
"syscall/js"
|
||||
|
||||
"github.com/syumai/workers/cloudflare/internal/cfruntimecontext"
|
||||
"github.com/syumai/workers/internal/jsutil"
|
||||
)
|
||||
|
||||
func WaitUntil(ctx context.Context, task func()) {
|
||||
executionContext := cfruntimecontext.GetExecutionContext(ctx)
|
||||
|
||||
executionContext.Call("waitUntil", jsutil.NewPromise(js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
task()
|
||||
return nil
|
||||
})))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user