Update SingletonRouter type to include ready and readyCallback funcs

This commit is contained in:
Scott Jones
2018-04-20 19:19:50 -04:00
parent fde7699456
commit 107dce1cae
2 changed files with 4 additions and 5 deletions
+2 -3
View File
@@ -10,9 +10,6 @@ export interface EventChangeOptions {
export type RouterCallback = () => void;
export interface RouterProps {
readyCallbacks: RouterCallback[];
ready(cb: RouterCallback): void;
// router properties
readonly components: {
[key: string]: { Component: React.ComponentType<any>; err: any };
@@ -55,6 +52,8 @@ export interface RouterProps {
export interface SingletonRouter {
router: RouterProps;
readyCallbacks: RouterCallback[];
ready(cb: RouterCallback): void;
}
export function withRouter<T extends {}>(
+2 -2
View File
@@ -2,10 +2,10 @@ import Router, * as r from "next/router";
import * as React from "react";
import * as qs from "querystring";
Router.router.readyCallbacks.push(() => {
Router.readyCallbacks.push(() => {
console.log("I'll get called when the router initializes.");
});
Router.router.ready(() => {
Router.ready(() => {
console.log(
"I'll get called immediately if the router initializes, or when it eventually does.",
);