Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

rename preloadRoutes to prefetchRoutes #167

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export function goto(href: string, opts = { replaceState: false }) {
}
}

export function preloadRoutes(pathnames: string[]) {
export function prefetchRoutes(pathnames: string[]) {
if (!routes) throw new Error(`You must call init() first`);

return routes
Expand All @@ -281,4 +281,7 @@ export function preloadRoutes(pathnames: string[]) {
.reduce((promise: Promise<any>, route) => {
return promise.then(route.load);
}, Promise.resolve());
}
}

// remove this in 0.9
export { prefetchRoutes as preloadRoutes };
4 changes: 2 additions & 2 deletions test/app/app/client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { init, preloadRoutes } from '../../../runtime.js';
import { init, prefetchRoutes } from '../../../runtime.js';
import { routes } from './manifest/client.js';

window.init = () => {
return init(document.querySelector('#sapper'), routes);
};

window.preloadRoutes = preloadRoutes;
window.prefetchRoutes = prefetchRoutes;
6 changes: 3 additions & 3 deletions test/common/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Nightmare.action('init', function(done) {
this.evaluate_now(() => window.init(), done);
});

Nightmare.action('preloadRoutes', function(done) {
this.evaluate_now(() => window.preloadRoutes(), done);
Nightmare.action('prefetchRoutes', function(done) {
this.evaluate_now(() => window.prefetchRoutes(), done);
});

function run(env) {
Expand Down Expand Up @@ -159,7 +159,7 @@ function run(env) {
});

it('navigates to a new page without reloading', () => {
return capture(() => nightmare.goto(base).init().preloadRoutes())
return capture(() => nightmare.goto(base).init().prefetchRoutes())
.then(() => {
return capture(() => nightmare.click('a[href="/about"]'));
})
Expand Down