-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(signal-state): Introducing a new library to the S-Libs family: S…
…ignal State! A state management library similar to App State, built on Angular Signals instead of RxJS.
- Loading branch information
Showing
44 changed files
with
1,442 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
projects/integration/src/app/api-tests/signal-store.spec.ts
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,15 @@ | ||
import { PersistentStore, RootStore, Store } from '@s-libs/signal-store'; | ||
|
||
describe('signal-store', () => { | ||
it('has PersistentStore', () => { | ||
expect(PersistentStore).toBeDefined(); | ||
}); | ||
|
||
it('has RootStore', () => { | ||
expect(RootStore).toBeDefined(); | ||
}); | ||
|
||
it('has Store', () => { | ||
expect(Store).toBeDefined(); | ||
}); | ||
}); |
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
6 changes: 6 additions & 0 deletions
6
...gration/src/app/signal-store-performance/deep-performance/deep-performance.component.html
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 @@ | ||
<br /> | ||
<input [(ngModel)]="depth" /> Depth | ||
<br /> | ||
<input [(ngModel)]="iterations" /> Iterations | ||
<br /> | ||
<button (click)="run()">Run</button> |
39 changes: 39 additions & 0 deletions
39
...tegration/src/app/signal-store-performance/deep-performance/deep-performance.component.ts
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,39 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
createEnvironmentInjector, | ||
EnvironmentInjector, | ||
inject, | ||
} from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { RootStore } from '@s-libs/signal-store'; | ||
import { | ||
DeepState, | ||
runDeep, | ||
subscribeDeep, | ||
} from '../../../../../signal-store/src/performance/deep-performance'; | ||
import { unsubscribe } from '../../../../../signal-store/src/performance/performance-utils'; | ||
|
||
@Component({ | ||
selector: 'sl-deep-performance', | ||
templateUrl: './deep-performance.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [FormsModule], | ||
}) | ||
export class DeepPerformanceComponent { | ||
protected depth = 1000; | ||
protected iterations = 1000; | ||
|
||
#injector = inject(EnvironmentInjector); | ||
|
||
protected async run(): Promise<void> { | ||
// `any` because we import functions directly from `signal-store` and TS doesn't like that | ||
const store: any = new RootStore(new DeepState(this.depth)); | ||
const injector = createEnvironmentInjector([], this.#injector); | ||
|
||
subscribeDeep(store, injector); | ||
await runDeep(store, this.iterations, async () => Promise.resolve()); | ||
unsubscribe(this.depth, injector); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ects/integration/src/app/signal-store-performance/signal-store-performance.component.html
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,3 @@ | ||
<sl-wide-performance /> | ||
<hr /> | ||
<sl-deep-performance /> |
Empty file.
13 changes: 13 additions & 0 deletions
13
projects/integration/src/app/signal-store-performance/signal-store-performance.component.ts
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,13 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { DeepPerformanceComponent } from './deep-performance/deep-performance.component'; | ||
import { WidePerformanceComponent } from './wide-performance/wide-performance.component'; | ||
|
||
@Component({ | ||
selector: 'sl-signal-store-performance', | ||
templateUrl: './signal-store-performance.component.html', | ||
styleUrls: ['./signal-store-performance.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [DeepPerformanceComponent, WidePerformanceComponent], | ||
}) | ||
export class SignalStorePerformanceComponent {} |
6 changes: 6 additions & 0 deletions
6
...gration/src/app/signal-store-performance/wide-performance/wide-performance.component.html
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 @@ | ||
<br /> | ||
<input [(ngModel)]="width" /> Width | ||
<br /> | ||
<input [(ngModel)]="iterations" /> Iterations | ||
<br /> | ||
<button (click)="run()">Run</button> |
39 changes: 39 additions & 0 deletions
39
...tegration/src/app/signal-store-performance/wide-performance/wide-performance.component.ts
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,39 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
createEnvironmentInjector, | ||
EnvironmentInjector, | ||
inject, | ||
} from '@angular/core'; | ||
import { RootStore } from '@s-libs/signal-store'; | ||
import { unsubscribe } from '../../../../../signal-store/src/performance/performance-utils'; | ||
import { | ||
runWide, | ||
subscribeWide, | ||
WideState, | ||
} from '../../../../../signal-store/src/performance/wide-performance'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'sl-wide-performance', | ||
templateUrl: './wide-performance.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [FormsModule], | ||
}) | ||
export class WidePerformanceComponent { | ||
protected width = 1000; | ||
protected iterations = 1000; | ||
|
||
#injector = inject(EnvironmentInjector); | ||
|
||
protected async run(): Promise<void> { | ||
// `any` because we import functions directly from `signal-store` and TS doesn't like that | ||
const store: any = new RootStore(new WideState(this.width)); | ||
const injector = createEnvironmentInjector([], this.#injector); | ||
|
||
subscribeWide(store, injector); | ||
await runWide(store, this.iterations, async () => Promise.resolve()); | ||
unsubscribe(this.width, injector); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "../../.eslintrc.json", | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts"], | ||
"parserOptions": { | ||
"project": ["projects/signal-store/tsconfig.(lib|spec).json"] | ||
}, | ||
"rules": {} | ||
}, | ||
{ "files": ["*.html"], "rules": {} } | ||
] | ||
} |
Oops, something went wrong.