-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #783 from /issues/694
feat(core): factories for factory selectors for ngrx 12+ #694
- Loading branch information
Showing
20 changed files
with
270 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ dist | |
node_modules | ||
test-reports | ||
tmp | ||
|
||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
git update-index --again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged | ||
npm run lint | ||
npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: toFactorySelector | ||
description: Information about toFactorySelector function and how to create a factory selector function | ||
sidebar_label: toFactorySelector | ||
--- | ||
|
||
`toFactorySelector` helps to create a factory selector function from a root selector. | ||
In this case, the produced selector can be passed directly to NGRX `store.select`. | ||
|
||
This function is useful for NGRX v12 and younger. | ||
|
||
```ts | ||
export class MyComponent { | ||
public readonly users$: Observable<User>; | ||
|
||
private readonly selectUser = | ||
toFactorySelector( | ||
rootUser( | ||
relUserCompany( | ||
relCompanyAddress(), | ||
), | ||
), | ||
); | ||
|
||
constructor(private store: Store) { | ||
this.users$ = this.store.select( | ||
// let's select current user | ||
this.selectUser( | ||
selectCurrentUserId, | ||
), | ||
); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: toStaticSelector | ||
description: Information about toStaticSelector function and how to bind param to a root selector | ||
sidebar_label: toStaticSelector | ||
--- | ||
|
||
`toStaticSelector` helps to create a selector function from a root selector. | ||
Its behavior very similar to [`toFactorySelector`](./to-factory-selector.md), | ||
with the difference that the passed params are static and cannot be changed. | ||
|
||
This function is useful for NGRX v12 and younger. | ||
|
||
```ts | ||
export class MyComponent { | ||
public readonly users$: Observable<User>; | ||
|
||
private readonly selectCurrentUser = | ||
toStaticSelector( | ||
rootUser( | ||
relUserCompany( | ||
relCompanyAddress(), | ||
), | ||
), | ||
selectCurrentUserId, | ||
); | ||
|
||
constructor(private store: Store) { | ||
this.users$ = this.store.select( | ||
this.selectCurrentUser, | ||
); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.