Skip to content

Commit 36b6724

Browse files
committed
add types for routerAjaxStart
1 parent dede8e8 commit 36b6724

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/core/modules/router/router-class.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,14 @@ class Router extends Framework7Class {
539539
}
540540
}
541541
router.xhrAbortController = new AbortController();
542-
const options = {
542+
const fetchOptions = {
543543
method: 'GET',
544544
signal: router.xhrAbortController.signal,
545545
};
546-
router.emit('routerAjaxStart', options);
546+
router.emit('routerAjaxStart', options, fetchOptions);
547547
let fetchRes;
548-
fetch(url, options).then(res => {
548+
fetch(url, fetchOptions)
549+
.then((res) => {
549550
fetchRes = res;
550551
return res.text();
551552
})

src/core/modules/router/router.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ export namespace Router {
247247
/** Event will be fired when router.updateCurrentUrl method called */
248248
routeUrlUpdate(newRoute: Route, router: Router): void;
249249

250+
/** Event will be fired when the request starts. As an arguments receives navigating options object and request init object */
251+
routerAjaxStart(options: RouteOptions, requestInit: RequestInit): void;
250252
/** Event will be fired when the request succeeds. As an arguments receives XHR object and navigating options object */
251253
routerAjaxSuccess(response: Response, options: RouteOptions): void;
252254
/** Event will be fired if the request fails. As an arguments receives XHR object and navigating options object */

0 commit comments

Comments
 (0)