RFC: Allow partial Route params updates
- Dominant language
- TypeScript
- Stars
- 8
- Forks
- 2
- Avg merge
- 13h 44m
- Merged PRs (30d)
- 1
Description
Source issue: https://github.com/atomic-router/atomic-router/issues/59
Use-case:
```ts
export const mainRoute = createRoute<{
categoryId?: string;
locationId?: string;
}>();
sample({
clock: selectLocation,
source: mainRoute.$params,
fn: (params, id) => ({ ...params, locationId: id }),
target: mainRoute.open,
});
sample({
clock: unselectLocation,
source: mainRoute.$params,
fn: (params, id) => ({ ...params, locationId: undefined }),
target: mainRoute.open,
});
```
```ts
const routes = [
{ path: '/:locale/users/:userId/posts', route: postsRoute },
{ path: '/:locale/users/:userId/posts/:postId', route: postRoute },
];
const router = createHistoryRouter({ routes });
// current url: /en/users/123/posts
postRoute.open({ postId: "456" })
// updated url: /en/users/123/posts/456
```
Contributor guide
Assessment
This issue has not been assessed yet.