@reach/router#NavigateFn TypeScript Examples

The following examples show how to use @reach/router#NavigateFn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ITwinViewerApp.ts    From viewer with MIT License 6 votes vote down vote up
public static initializeMenuListeners(
    navigate: NavigateFn,
    userSettings: Settings
  ) {
    if (this._menuListener) {
      // initialize only once
      return;
    }
    this._menuListener = async (sender, arg) => {
      switch (arg) {
        case "open":
          const filePath = await ITwinViewerApp.getFile();
          if (filePath) {
            void userSettings.addRecent(filePath);
            await navigate(`/viewer`, { state: { filePath } });
          }
          break;
        case "download":
          await navigate("/itwins");
          break;
        case "home":
          await navigate("/");
          break;
        case "preferences":
          alert("Coming Soon!");
          break;
      }
    };
    IpcApp.addListener(channelName, this._menuListener);
  }