Closed danielnc closed 1 year ago
@danielnc request.js does not emit any before/after events; You can get exactly that behavior by doing what readme https://github.com/rails/request.js#before-and-after-hooks suggests doing. Note the last function that is exported
export function get(url, options) {
const request = new FetchRequest("get", url, options)
return withProgress(request.perform())
}
^ In the JS files, you want to import and call this get
function instead the one request.js
exports.
I have a couple of places where I am using request.js and I want to globally opt-in to specific before/after requests start/complete so I can give user proper feedback, showing progress-bar
Similar to how turbo uses progress bar for long running requests but I couldn't find a way to listen to specific events
does request.js supports listening to before/after events?
I know there is an example for withPgoress wrapping the function, but I want to use that globally instead of having to call it on every single request.js call