Skip to content

Commit 8dced76

Browse files
committed
feat: initial commit
Release-As: 0.1.0
0 parents  commit 8dced76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+21651
-0
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: k3nsei
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Install Dependencies
2+
description: Install node.js and install npm dependencies
3+
4+
inputs:
5+
node-version:
6+
description: 'Which version of Node.js to install'
7+
required: false
8+
default: 'lts/*'
9+
registry-url:
10+
description: 'Which NPM registry url to use'
11+
required: false
12+
default: 'https://registry.npmjs.org'
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Setup Node.js and NPM
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ inputs.node-version }}
21+
registry-url: ${{ inputs.registry-url }}
22+
cache: 'npm'
23+
cache-dependency-path: '**/package-lock.json'
24+
25+
- name: Install NPM dependencies
26+
shell: bash
27+
run: npm ci

.github/workflows/pr.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: pr
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
branches: [main]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
pr:
16+
name: Run build and unit tests
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install dependencies
23+
uses: ./.github/actions/install-npm-deps
24+
25+
- name: Build
26+
run: npx --no -- ng build ngx-signal-store-query

.github/workflows/release-please.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
reason:
9+
description: Why was the workflow triggered manually?
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
id-token: write
17+
18+
jobs:
19+
release-please:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Prepare release PR or move on with release when PR was accepted
23+
id: release
24+
uses: google-github-actions/release-please-action@v4
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
release-type: node
28+
package-name: '@ngx-signal-store-query/core'
29+
extra-files: |
30+
LICENSE
31+
README.md
32+
33+
- name: Checkout repository
34+
if: ${{ steps.release.outputs.release_created }}
35+
uses: actions/checkout@v4
36+
37+
- name: Setup NodeJS
38+
if: ${{ steps.release.outputs.release_created }}
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: 'lts/*'
42+
registry-url: 'https://registry.npmjs.org'
43+
cache: 'npm'
44+
cache-dependency-path: '**/package-lock.json'
45+
46+
- name: Install NPM dependencies
47+
if: ${{ steps.release.outputs.release_created }}
48+
shell: bash
49+
run: npm ci
50+
51+
- name: Build
52+
if: ${{ steps.release.outputs.release_created }}
53+
shell: bash
54+
run: npx --no -- ng build ngx-signal-store-query
55+
56+
- name: Copy extra files
57+
if: ${{ steps.release.outputs.release_created }}
58+
shell: bash
59+
run: |
60+
cp LICENSE dist/libs/ngx-signal-store-query/LICENSE
61+
cp README.md dist/libs/ngx-signal-store-query/README.md
62+
63+
- name: Publish
64+
if: ${{ steps.release.outputs.release_created }}
65+
env:
66+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
67+
shell: bash
68+
run: |
69+
cd dist/libs/ngx-signal-store-query
70+
npm publish --provenance --access public

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db

.husky/commit-msg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
[ -n "$CI" ] && exit 0
4+
5+
npx --no -- commitlint --edit "${1}"

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
[ -n "$CI" ] && exit 0
4+
5+
npx --no -- lint-staged --allow-empty

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.angular
2+
/.husky/_
3+
/coverage
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out

.vscode/extensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": ["angular.ng-template"]
4+
}

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"name": "ng serve",
7+
"type": "chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:4200/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test",
17+
"url": "http://localhost:9876/debug.html"
18+
}
19+
]
20+
}

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3+
"version": "2.0.0",
4+
"tasks": [
5+
{
6+
"type": "npm",
7+
"script": "start",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "typescript",
11+
"pattern": "$tsc",
12+
"background": {
13+
"activeOnStart": true,
14+
"beginsPattern": {
15+
"regexp": "(.*?)"
16+
},
17+
"endsPattern": {
18+
"regexp": "bundle generation complete"
19+
}
20+
}
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "test",
26+
"isBackground": true,
27+
"problemMatcher": {
28+
"owner": "typescript",
29+
"pattern": "$tsc",
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": {
33+
"regexp": "(.*?)"
34+
},
35+
"endsPattern": {
36+
"regexp": "bundle generation complete"
37+
}
38+
}
39+
}
40+
}
41+
]
42+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Piotr Stępniewski
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ngx-signal-store-query
2+
3+
Signal Store feature that bridges with Angular Query
4+
5+
## Simple Example
6+
7+
#### Create Store
8+
9+
```typescript
10+
import { signalStore, withState } from '@ngrx/signals';
11+
import { withQuery } from '@ngx-signal-store-query/core';
12+
import { lastValueFrom } from 'rxjs';
13+
14+
import { ApiService } from './api.service';
15+
16+
export const ExampleStore = signalStore(
17+
withState({ categoryId: 1 }),
18+
withQuery('example', (store) => {
19+
const apiService = inject(ApiService);
20+
21+
return () => {
22+
const categoryId = store.categoryId();
23+
24+
return {
25+
enabled: !!categoryId,
26+
queryKey: ['category', { id: categoryId }],
27+
queryFn: () =>
28+
lastValueFrom(apiService.getCategory$(categoryId)).catch((error) => {
29+
console.error(error);
30+
31+
return null;
32+
}),
33+
};
34+
};
35+
}),
36+
);
37+
```
38+
39+
#### Use it in component
40+
41+
```typescript
42+
import { JsonPipe } from '@angular/common';
43+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
44+
45+
import { ExampleStore } from './example.store.ts';
46+
47+
@Component({
48+
standalone: true,
49+
selector: 'app-example',
50+
template: `
51+
<pre>
52+
Loading: {{ store.exampleQuery().isLoading() }}
53+
Fetching: {{ store.exampleQuery().isFetching() }}
54+
Data:
55+
{{ store.exampleQuery().data() | json }}
56+
</pre>
57+
`,
58+
changeDetection: ChangeDetectionStrategy.OnPush,
59+
imports: [JsonPipe],
60+
})
61+
export class ExampleComponent {
62+
public readonly store = inject(ExampleStore);
63+
}
64+
```

0 commit comments

Comments
 (0)