Closed Yahav closed 2 years ago
You can see a sample code of the sequence option in tests.
https://github.com/falsandtru/pjax-api/blob/v3.33.2/test/integration/package.ts#L65
I really don't get it. any real life (no tests) usage of this available?
No. That sample is very readable. You should write your code by rewriting that sample.
I tried the following, just to see what happens:
const sequence = {
async fetch(r, req) {
console.log('fetch', r, req);
return 1;
},
async unload(r, res) {
console.log('unload', r, red);
return 2;
},
async content(r, areas) {
console.log('content', r, areas);
return 3;
},
async ready(r) {
console.log('ready', r);
return 4;
},
async load(r, events) {
console.log('load', r, events);
done();
}
};
new Pjax({
sequence: sequence,
areas: [
// Try the first query.
'#site-content, #navbarMenuDesktop .ui.header, #casterfmCloudProperties',
]
});
when loading a page, after the first console.log (fetch), it just redirects...
You must remove done()
.
removed, still happens
I think its related to the args of one of the functions because when i run it like this it works:
const sequence = {
async fetch() {
return 1;
},
async unload() {
return 2;
},
async content() {
return 3;
},
async ready() {
return 4;
},
async load() {
}
};
Misspelling
async unload(r, res) {
console.log('unload', r, red); // <-
return 2;
},
Yap, got that. still trying to figure out how do i add headers to the request in stage one.
Which one of the sequence is fired only after all the additional scripts has finished loading?
Lets say i'd like to add a header to the requests and do something after the response but before the DOM change, how would i go about that?