Skip to content

Commit

Permalink
refactor(router): in onNavigateTo args rename cancelled to `navig…
Browse files Browse the repository at this point in the history
…ationWasCancelled`
  • Loading branch information
MrWolfZ committed Jan 2, 2021
1 parent cd249ae commit da4359f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/router/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export type OnNavigateTo<TParameters = NavigationParameters> = (parameters: Immu

// @public
export interface OnNavigateToExtras {
readonly cancelled: Promise<typeof NAVIGATION_CANCELLED>;
readonly cancelNavigation: typeof NAVIGATION_CANCELLED;
readonly navigationIsToChildRoute: boolean;
readonly navigationWasCancelled: Promise<typeof NAVIGATION_CANCELLED>;
}

// @public
Expand Down
8 changes: 4 additions & 4 deletions packages/router/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ describe(`@simplux/router`, () => {

let cancelledNavigation = new Promise<typeof NAVIGATION_CANCELLED>(() => {})
const cancelledNavRoute = router.addRoute('asyncNever', {
onNavigateTo: (_, { cancelled }) => {
cancelledNavigation = cancelled
onNavigateTo: (_, { navigationWasCancelled }) => {
cancelledNavigation = navigationWasCancelled
return new Promise<void>(() => {})
},
})
Expand All @@ -63,7 +63,7 @@ describe(`@simplux/router`, () => {
cancelledNavRoute.onNavigateTo(
{},
{
cancelled: undefined!,
navigationWasCancelled: undefined!,
cancelNavigation: NAVIGATION_CANCELLED,
navigationIsToChildRoute: false,
},
Expand All @@ -78,7 +78,7 @@ describe(`@simplux/router`, () => {
await routeThatCancelsNav.onNavigateTo(
{},
{
cancelled: undefined!,
navigationWasCancelled: undefined!,
cancelNavigation: NAVIGATION_CANCELLED,
navigationIsToChildRoute: false,
},
Expand Down
12 changes: 6 additions & 6 deletions packages/router/src/module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ describe(`module`, () => {

const interceptor = jest
.fn<Promise<void>, [any, OnNavigateToExtras]>()
.mockImplementationOnce((_, { cancelled }) => {
cancellationPromise = cancelled
.mockImplementationOnce((_, { navigationWasCancelled }) => {
cancellationPromise = navigationWasCancelled
return new Promise<void>(() => {})
})

Expand Down Expand Up @@ -1320,8 +1320,8 @@ describe(`module`, () => {

const childInterceptor = jest
.fn<Promise<void>, [any, OnNavigateToExtras]>()
.mockImplementationOnce((_, { cancelled }) => {
childCancellationPromise = cancelled
.mockImplementationOnce((_, { navigationWasCancelled }) => {
childCancellationPromise = navigationWasCancelled
return new Promise<void>(() => {})
})

Expand Down Expand Up @@ -1363,8 +1363,8 @@ describe(`module`, () => {

const parentInterceptor = jest
.fn<Promise<void>, [any, OnNavigateToExtras]>()
.mockImplementationOnce((_, { cancelled }) => {
parentCancellationPromise = cancelled
.mockImplementationOnce((_, { navigationWasCancelled }) => {
parentCancellationPromise = navigationWasCancelled
return new Promise<void>(() => {})
})

Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface OnNavigateToExtras {
* (e.g. because a new navigation has started while this
* function was running).
*/
readonly cancelled: Promise<typeof NAVIGATION_CANCELLED>
readonly navigationWasCancelled: Promise<typeof NAVIGATION_CANCELLED>

/**
* This object can be returned to cancel the navigation.
Expand Down Expand Up @@ -291,7 +291,7 @@ const effects = createEffects({

if (interceptor) {
const onNavigateToExtras: OnNavigateToExtras = {
cancelled: cancellationPromise,
navigationWasCancelled: cancellationPromise,
cancelNavigation: NAVIGATION_CANCELLED,
navigationIsToChildRoute: routeId !== targetRouteId,
}
Expand Down

0 comments on commit da4359f

Please sign in to comment.