effector / effector/router

RFC: Allow partial Route params updates

Open
#34 0 comments 0 reactions 1 assignee Claimed by @sergeysova View on GitHub
enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.