angular / angular/angular

Expose strategies that correspond to string values of runGuardsAndResolvers

Open
#53,946 1 comment 12 reactions 0 assignees View on GitHub
area: router feature
Dominant language
TypeScript
Stars
101k
Forks
27.5k
Avg merge
1d 19h
Merged PRs (30d)
288

Description

### Which @angular/* package(s) are relevant/related to the feature request?

router

### Description

Given that runGuardsAndResolvers may take a custom strategy in form of a function, it makes sense to expose the set of predefined strategies `'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always'` so that consumers can compose with them, as was done in case of defaultUrlMatcher, see https://github.com/angular/angular/issues/35928. Also related https://github.com/angular/angular/issues/31843#issuecomment-1890955590

### Proposed solution

Make the strategies part of public api:

```
import { RunGuardsAndResolversStrategies } from '@angular/router';
```

Being:

```
class RunGuardsAndResolversStrategies {
static pathParamsChange() { ... }
static pathParamsOrQueryParamsChange() { ... }
static paramsChange() { ... }
static paramsOrQueryParamsChange() { ... }
static always() { ... }
}
```

### Alternatives considered

Copy paste the code from Angular source code or reimplement said strategies.

Contributor guide

Open the contributing guide

Research direction

Start in the @angular/router implementation of runGuardsAndResolvers and trace how its predefined string strategies are defined and exported through the public router entry point. The work is done when the five strategies are publicly importable as RunGuardsAndResolversStrategies and can be composed by consumers without reimplementing them.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.