Skip to content

fix(store): rename storeService #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ A short example can be found here

The util returns an Observable for easy further chaining throughout the application.

### StoreService
### NgxStoreService

Just as the aforementioned `dispatchDataToStore` util, the `StoreService` abstraction works best in tandem with the `createStoreAssets` util.
Just as the aforementioned `dispatchDataToStore` util, the `NgxStoreService` abstraction works best in tandem with the `createStoreAssets` util.

This abstraction provides easy access to the selectors that were generated by the assets. These are aimed to reduce the boilerplate and create a coherent store setup throughout your entire application. By passing the selector object to the methods, the abstraction will automatically handle the selection.

Expand All @@ -137,7 +137,7 @@ This abstraction provides easy access to the selectors that were generated by th
| selectErrorFromStore | Selects the error state of the provided data from the store |
| selectErrorMessageFromStore | Selects the provided error data of the provided data from the store |

On top of that, the `StoreService` can automatically generate observables for each sub-slice in the provided store. By providing the store interface to the `StoreService` via generics and passing the generated selectors to the constructor, a state object is generated including all the necessary observables.
On top of that, the `NgxStoreService` can automatically generate observables for each sub-slice in the provided store. By providing the store interface to the `NgxStoreService` via generics and passing the generated selectors to the constructor, a state object is generated including all the necessary observables.

A short example would be:

Expand All @@ -154,7 +154,7 @@ export const { actions, reducers, selectors } = createStoreAssets<StoreState>('s
]);

@Injectable()
export class StoreStateService extends StoreService<StoreState> {
export class StoreStateService extends NgxStoreService<StoreState> {
constructor(protected readonly store: Store) {
super(store, selectors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Each of the provided utils can be used individually, but we strongly advice to u

As mentioned before, `ngx-store` works in tandem with `@ngrx`. The package aims to optimize the workflow for (complex) projects that currently already use this redux implementation.

With this in mind, our goal is to make this package as flexible as possible. We are aware that existing projects often already have their own approach to their store setup, and therefor we try to provide solutions that can be used when needed. Whilst we strongly suggest using the entire system for the optimal approach, several of our utils are entirely optional. The use of `handleEffect`, `dispatchDataToStore` and the `StoreService` is never mandatory and all utils are opt-in at any stage.
With this in mind, our goal is to make this package as flexible as possible. We are aware that existing projects often already have their own approach to their store setup, and therefor we try to provide solutions that can be used when needed. Whilst we strongly suggest using the entire system for the optimal approach, several of our utils are entirely optional. The use of `handleEffect`, `dispatchDataToStore` and the `NgxStoreService` is never mandatory and all utils are opt-in at any stage.

Because of this approach, our implementation has to take into account these constraints and will therefore deviate from the standard redux implementation.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TableViewComponent extends NgxQueryParamFormSyncComponent<
constructor(
readonly route: ActivatedRoute,
readonly router: Router,
readonly storeService: StoreService
readonly storeService: NgxStoreService
) {
super(route, router);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/store-test/src/services/courses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Store } from '@ngrx/store';
import { of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { CoursesStore, actions, selectors } from '../store/courses.store';
import { StoreService, dispatchDataToStore } from '@ngx/store';
import { NgxStoreService, dispatchDataToStore } from '@ngx/store';

@Injectable()
export class CoursesService extends StoreService<CoursesStore> {
export class CoursesService extends NgxStoreService<CoursesStore> {
constructor(protected readonly store: Store) {
super(store, selectors);
}
Expand Down
2 changes: 1 addition & 1 deletion libs/angular/store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For more information about the build process, authors, contributions and issues,

As mentioned before, `ngx-store` works in tandem with `@ngrx`. The package aims to optimize the workflow for (complex) projects that currently already use this redux implementation.

With this in mind, our goal is to make this package as flexible as possible. We are aware that existing projects often already have their own approach to their store setup, and therefor we try to provide solutions that can be used when needed. Whilst we strongly suggest using the entire system for the optimal approach, several of our utils are entirely optional. The use of `handleEffect`, `dispatchDataToStore` and the `StoreService` is never mandatory and all utils are opt-in at any stage.
With this in mind, our goal is to make this package as flexible as possible. We are aware that existing projects often already have their own approach to their store setup, and therefor we try to provide solutions that can be used when needed. Whilst we strongly suggest using the entire system for the optimal approach, several of our utils are entirely optional. The use of `handleEffect`, `dispatchDataToStore` and the `NgxStoreService` is never mandatory and all utils are opt-in at any stage.

Because of this approach, our implementation has to take into account these constraints and will therefore deviate from the standard redux implementation.

Expand Down
4 changes: 2 additions & 2 deletions libs/angular/store/src/lib/store/abstracts/store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { NgxStoreSelectors, StoreFlowAssets, StoreState } from '../interfaces';

@Injectable()
export class StoreService<StoreAssetsType extends StoreFlowAssets = any> {
export class NgxStoreService<StoreAssetsType extends StoreFlowAssets = any> {
/**
* A wrapper object for the store state selectors
*/
Expand Down Expand Up @@ -76,7 +76,7 @@ export class StoreService<StoreAssetsType extends StoreFlowAssets = any> {
// Iben: If no selectors were provided, we throw an error informing the user
if (!this.stateWrapper) {
console.error(
'NgxStore: No selectors were provided to the constructor of the StoreService extender. Without it, the state object cannot be created and will result in an error.'
'NgxStore: No selectors were provided to the constructor of the NgxStoreService extender. Without it, the state object cannot be created and will result in an error.'
);

return undefined;
Expand Down
4 changes: 2 additions & 2 deletions libs/angular/store/src/lib/store/spec/store-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Observable } from 'rxjs';
import { switchMap } from 'rxjs/operators';

import { HttpClient } from '@angular/common/http';
import { StoreService } from '../abstracts';
import { NgxStoreService } from '../abstracts';
import { dispatchDataToStore } from '../utils';
import { DataType, actions, selectors } from './store-assets';

@Injectable()
export class SpecStoreService extends StoreService {
export class SpecStoreService extends NgxStoreService {
public readonly channel$: Observable<DataType> = this.selectFromStore<DataType>(
selectors.channel
);
Expand Down
4 changes: 2 additions & 2 deletions libs/angular/store/src/lib/store/spec/store-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
createStoreAssets,
dispatchDataToStore,
} from '../utils';
import { StoreService } from '../abstracts';
import { NgxStoreService } from '../abstracts';

interface StoreState extends StoreFlowAssets {
data: EntityStoreAssets<string>;
Expand All @@ -28,7 +28,7 @@ export const { actions, reducers, selectors } = createStoreAssets<StoreState>('s
]);

@Injectable()
export class StoreStateService extends StoreService<StoreState> {
export class StoreStateService extends NgxStoreService<StoreState> {
constructor(protected readonly store: Store) {
super(store, selectors);
}
Expand Down
2 changes: 1 addition & 1 deletion libs/angular/store/src/lib/store/spec/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const mockVideos = [
{ id: 'two', url: 'hello.world' },
];

// Iben: These tests test the StoreService abstraction, dispatchDataToStore and StoreAssets in one go.
// Iben: These tests test the NgxStoreService abstraction, dispatchDataToStore and StoreAssets in one go.
// TODO: Find a way to add an error flow test.
describe('NgxStore', () => {
let service: SpecStoreService;
Expand Down
2 changes: 1 addition & 1 deletion libs/angular/store/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Public API Surface of store
*/
export { StoreService } from './lib/store/abstracts';
export { NgxStoreService } from './lib/store/abstracts';
export {
BaseStoreAssets,
EntityStoreAssets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class TableViewComponent extends NgxQueryParamFormSyncComponent<
constructor(
readonly route: ActivatedRoute,
readonly router: Router,
readonly storeService: StoreService
readonly storeService: NgxStoreService
) {
super(route, router);
}
Expand Down