Skip to content

Commit a54ceda

Browse files
committed
wip
1 parent 3fdfc05 commit a54ceda

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

pouchdb/bindings/pouchdb.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,16 @@ func setFetchOptions(ctx context.Context, options map[string]interface{}) map[st
8989
if ctx == nil { // Just to be safe
9090
return options
9191
}
92-
deadline, ok := ctx.Deadline()
93-
if !ok {
94-
return options
95-
}
9692
if options == nil {
9793
options = make(map[string]interface{})
9894
}
99-
if _, ok := options["ajax"]; !ok {
100-
options["ajax"] = make(map[string]interface{})
101-
}
102-
ajax := options["ajax"].(map[string]interface{})
103-
timeout := int(time.Until(deadline) * 1000) //nolint:gomnd
104-
// Used by ajax calls
105-
ajax["timeout"] = timeout
106-
// Used by changes and replications
107-
options["timeout"] = timeout
95+
controller := js.Global.Get("AbortController").New()
96+
options["fetch"] = js.MakeFunc(func(_ *js.Object, args []*js.Object) interface{} {
97+
url := args[0]
98+
return js.Global.Call("fetch", url, map[string]interface{}{
99+
"signal": controller.Get("signal"),
100+
})
101+
})
108102
return options
109103
}
110104

0 commit comments

Comments
 (0)