Skip to content

Commit

Permalink
feat: pass router to appContext hook
Browse files Browse the repository at this point in the history
  • Loading branch information
liximomo committed Sep 11, 2023
1 parent 8866820 commit 4e464e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/platform-shared/src/shared/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export class ApplicationImpl<Config extends {} = {}> {
}

private async _initAppContext() {
await this._pluginManager.runner.appContext(this._context);
await this._pluginManager.runner.appContext(this._context, {
router: this._router
});
}

private async _initAppComponent() {
Expand Down
6 changes: 5 additions & 1 deletion packages/platform-shared/src/shared/runtimPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import {
import { CustomRuntimePluginHooks } from '@shuvi/runtime';
import { createPluginCreator } from '@shuvi/shared/plugins';
import { IAppContext } from './applicationTypes';
import { IRouter } from './routerTypes';

export type AppComponent = unknown;
export type AppContextCtx = {
router: IRouter;
};

const init = createAsyncParallelHook<void>();
const appContext = createAsyncSeriesHook<IAppContext>();
const appContext = createAsyncSeriesHook<IAppContext, AppContextCtx>();
const appComponent = createAsyncSeriesWaterfallHook<
AppComponent,
IAppContext
Expand Down

0 comments on commit 4e464e9

Please sign in to comment.