Skip to content

Commit aeb6c07

Browse files
committed
Improve readability of createIntegration
1 parent 79a2b57 commit aeb6c07

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/integration.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ function scrollToHash(hash: string, fallbackTop?: boolean) {
3232
}
3333
}
3434

35+
/**
36+
* Store location history in a local variable.
37+
*
38+
* (other router integrations "store" state as urls in browser history)
39+
*/
3540
export function createMemoryHistory() {
3641
const entries = ["/"];
3742
let index = 0;
@@ -75,10 +80,16 @@ export function createMemoryHistory() {
7580
};
7681
}
7782

83+
type NotifyLocationChange = (value?: string | LocationChange) => void;
84+
85+
type CreateLocationChangeNotifier = (
86+
notify: NotifyLocationChange
87+
) => /* LocationChangeNotifier: */ () => void;
88+
7889
export function createIntegration(
7990
get: () => string | LocationChange,
8091
set: (next: LocationChange) => void,
81-
init?: (notify: (value?: string | LocationChange) => void) => () => void,
92+
init?: CreateLocationChangeNotifier,
8293
utils?: Partial<RouterUtils>
8394
): RouterIntegration {
8495
let ignore = false;

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export interface RouteContext {
132132
}
133133

134134
export interface RouterUtils {
135+
/** This produces the `href` attribute shown in the browser. */
135136
renderPath(path: string): string;
136137
parsePath(str: string): string;
137138
go(delta: number): void;

0 commit comments

Comments
 (0)