effector / effector/router

RFC: add `createTask` helper for `chainRoute`

Open
#42 0 comments 0 reactions 1 assignee Claimed by @sergeysova View on GitHub
enhancement RFC scope:core
Dominant language
TypeScript
Stars
8
Forks
2
Avg merge
13h 44m
Merged PRs (30d)
1

Description

## Source
- https://github.com/atomic-router/atomic-router/issues/45

## Summary
Add a reusable `createTask` helper so `chainRoute` can accept composable task-like effects instead of a growing set of inline props.

## Motivation
The upstream request wants to move some `chainRoute` configuration out of the `chainRoute` call itself, especially for auth/confirmation flows.

In effector/router terms, this could make `beforeOpen` and a possible `beforeClose` easier to compose and reuse without bloating the route API.

## Proposed API
```ts
chainRoute({
route,
beforeOpen: createTask({
trigger: authCheckStarted,
done: [alreadyAuthorized, authorizedSuccessfully],
fail: [notAuthorized, refreshTokenFailed],
}),
})
```

`createTask` would return an effect-like unit that:
- calls `trigger` when invoked
- forwards `done` to `doneData`
- forwards `fail` to `failData`
- can infer `done`/`fail` from `trigger` when `trigger` is already an `Effect`

## Notes
- This is adapted from atomic-router issue #45 for traceability.
- I searched effector/router for `createTask`, `chainRoute`, `beforeOpen`, and `beforeClose` duplicates and did not find an existing issue.
- If this lands, `beforeClose` could be expressed with the same helper for confirmation flows.

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.