Skip to content
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
2 changes: 2 additions & 0 deletions packages/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ export * from "./router";

export type {
ActionFunction,
ActionFunctionArgs,
DataRouteObject,
FormEncType,
FormMethod,
JsonFunction,
LoaderFunction,
LoaderFunctionArgs,
ParamParseKey,
Params,
PathMatch,
Expand Down
20 changes: 16 additions & 4 deletions packages/router/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,38 @@ export interface Submission {
}

/**
* Arguments passed to route loader/action functions
* @private
* Arguments passed to route loader/action functions. Same for now but we keep
* this as a private implementation detail in case they diverge in the future.
*/
export interface DataFunctionArgs {
interface DataFunctionArgs {
request: Request;
params: Params;
signal: AbortSignal;
}

/**
* Arguments passed to loader functions
*/
export interface LoaderFunctionArgs extends DataFunctionArgs {}

/**
* Arguments passed to action functions
*/
export interface ActionFunctionArgs extends DataFunctionArgs {}

/**
* Route loader function signature
*/
export interface LoaderFunction {
(args: DataFunctionArgs): Promise<Response> | Response | Promise<any> | any;
(args: LoaderFunctionArgs): Promise<Response> | Response | Promise<any> | any;
}

/**
* Route action function signature
*/
export interface ActionFunction {
(args: DataFunctionArgs): Promise<Response> | Response | Promise<any> | any;
(args: ActionFunctionArgs): Promise<Response> | Response | Promise<any> | any;
}

/**
Expand Down