Skip to content
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

Update to v19 #153

Merged
merged 2 commits into from
Jan 13, 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
1 change: 1 addition & 0 deletions apps/example-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core';

@Component({
selector: 'ngrx-traits-root',
standalone: false,
template: `<router-outlet />`,
styleUrls: ['./app.component.scss'],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { JsonPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, model } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
Expand All @@ -24,7 +23,7 @@ import { ProductFilter } from '../../models';
`,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [FormsModule, MatFormFieldModule, MatInputModule, JsonPipe],
imports: [FormsModule, MatFormFieldModule, MatInputModule],
})
export class ProductSearchFormComponent {
searchProduct = model<ProductFilter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';

import { ProductsBranchDropdownComponent } from './products-branch-dropdown.component';
import { ProductsBranchListComponent } from './products-branch-list.component';
import { ProductsBranchStore } from './products-branch.store';

@Component({
selector: 'infinite-scroll-page',
standalone: true,
imports: [
CommonModule,
ProductsBranchDropdownComponent,
ProductsBranchListComponent,
],
imports: [CommonModule, ProductsBranchDropdownComponent],
template: `<products-branch-dropdown />`,
styles: ``,
providers: [ProductsBranchStore],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { toSignal } from '@angular/core/rxjs-interop';
import { FormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { MatFormField, MatLabel } from '@angular/material/form-field';
import { MatIcon } from '@angular/material/icon';
import { MatInput } from '@angular/material/input';
import { MatList, MatListItem } from '@angular/material/list';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
Expand All @@ -28,7 +27,6 @@ import { ProductsBranchStore } from './products-branch.store';
MatList,
MatListItem,
MatButton,
MatIcon,
MatFormField,
MatInput,
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AsyncPipe, JsonPipe } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Component, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { RouterLink } from '@angular/router';
import { Sort } from '@ngrx-traits/common';
Expand Down Expand Up @@ -100,9 +99,7 @@ import { ProductsLocalStore } from './product.store';
ProductListComponent,
MatPaginatorModule,
MatButtonModule,
AsyncPipe,
ProductDetailComponent,
JsonPipe,
RouterLink,
],
providers: [ProductsLocalStore],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { Sort } from '@ngrx-traits/common';

import { ProductBasketComponent } from '../../../../components/product-basket/product-basket.component';
import { ProductDetailComponent } from '../../../../components/product-detail/product-detail.component';
import { Product } from '../../../../models';
import { ProductsShopStore } from '../../products-shop.store';
import { SmartProductDetailComponent } from '../smart-product-detail/smart-product-detail.component';
Expand Down Expand Up @@ -86,8 +84,6 @@ import { SmartProductDetailComponent } from '../smart-product-detail/smart-produ
MatProgressSpinnerModule,
ProductBasketComponent,
MatButtonModule,
ProductDetailComponent,
AsyncPipe,
SmartProductDetailComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AsyncPipe } from '@angular/common';
import { Component, computed, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
Expand Down Expand Up @@ -85,7 +84,6 @@ import { ProductsShopStore } from '../../products-shop.store';
MatButtonModule,
ProductListComponent,
ProductDetailComponent,
AsyncPipe,
MatPaginator,
],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { MatBadgeModule } from '@angular/material/badge';
import { MatIconModule } from '@angular/material/icon';
Expand Down Expand Up @@ -59,7 +58,6 @@ import { ProductsShopStore } from './products-shop.store';
MatIconModule,
MatBadgeModule,
RouterOutlet,
AsyncPipe,
],
})
export class ProductShopPageContainerComponent {
Expand Down
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { getJestProjects } = require('@nx/jest');
const { getJestProjectsAsync } = require('@nx/jest');

export default { projects: getJestProjects() };
export default async () => ({ projects: await getJestProjectsAsync() });
12 changes: 6 additions & 6 deletions libs/ngrx-traits/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"postinstall": "ngcc"
},
"peerDependencies": {
"@angular/core": "^18.0.5",
"@ngrx/effects": "^18.0.1",
"@ngrx/entity": "^18.0.1",
"@ngrx/store": "^18.0.1",
"@ngrx-traits/core": "^18.0.0"
"@angular/core": "^19.0.0",
"@ngrx/effects": "^19.0.0",
"@ngrx/entity": "^19.0.0",
"@ngrx/store": "^19.0.0",
"@ngrx-traits/core": "^19.0.0"
},
"optionalDependencies": {
"@angular/router": "^18.0.5"
"@angular/router": "^19.0.0"
},
"sideEffects": false,
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions libs/ngrx-traits/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"postinstall": "ngcc"
},
"peerDependencies": {
"@angular/core": "^18.0.5",
"@ngrx/effects": "^18.0.1",
"@ngrx/entity": "^18.0.1",
"@ngrx/store": "^18.0.1",
"@angular/core": "^19.0.0",
"@ngrx/effects": "^19.0.0",
"@ngrx/entity": "^19.0.0",
"@ngrx/store": "^19.0.0",
"rxjs": "^7.8.1"
},
"sideEffects": false,
Expand Down
6 changes: 3 additions & 3 deletions libs/ngrx-traits/signals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"build": "ng-packagr -p package.json"
},
"peerDependencies": {
"@angular/core": "^18.0.5",
"@ngrx/signals": "^18.1.0",
"@angular/core": "^19.0.0",
"@ngrx/signals": "^19.0.0",
"rxjs": "^7.8.1"
},
"optionalDependencies": {
"@angular/cdk": "^18.0.5"
"@angular/cdk": "^19.0.0"
},
"sideEffects": false,
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ export function withCallStatus<
}
> = {},
): SignalStoreFeature<
Input & { state: {}; computed: {}; methods: {} },
Input & { state: {}; props: {}; methods: {} },
Prop extends ''
? {
state: CallStatusState;
computed: CallStatusComputed<Error>;
props: CallStatusComputed<Error>;
methods: CallStatusMethods<Error>;
}
: {
state: NamedCallStatusState<Prop>;
computed: NamedCallStatusComputed<Prop, Error>;
props: NamedCallStatusComputed<Prop, Error>;
methods: NamedCallStatusMethods<Prop, Error>;
}
> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ describe('withCalls', () => {
it('when withCall has mapPipe = switchMap should only process last call', fakeAsync(() => {
let aux = 0;
const call = jest.fn().mockImplementation(() => {
console.log('call');
aux++;
return of('' + aux).pipe(delay(100));
});
Expand Down Expand Up @@ -786,7 +785,6 @@ describe('withCalls', () => {
it('when withCall has mapPipe= exhaustMap should only process first call', fakeAsync(() => {
let aux = 0;
const call = jest.fn().mockImplementation(() => {
console.log('call');
aux++;
return of('' + aux).pipe(delay(100));
});
Expand Down Expand Up @@ -817,7 +815,6 @@ describe('withCalls', () => {
it('when withCall has mapPipe = concatMap should process all calls in sequence', fakeAsync(() => {
let aux = 0;
const call = jest.fn().mockImplementation(() => {
console.log('call');
aux++;
return of('' + aux).pipe(delay(100));
});
Expand Down
2 changes: 1 addition & 1 deletion libs/ngrx-traits/signals/src/lib/with-calls/with-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function withCalls<
: Calls[K]['resultProp'] & string
: `${K & string}Result`]: ExtractCallResultType<Calls[K]> | undefined;
};
computed: NamedCallsStatusComputed<keyof Calls & string> &
props: NamedCallsStatusComputed<keyof Calls & string> &
NamedCallsStatusErrorComputed<Calls>;
methods: {
[K in keyof Calls]: Calls[K] extends (...args: infer P) => any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('withEntitiesLocalFilter', () => {
patchState(store, setAllEntities(mockProducts));
store.setLoaded();
TestBed.flushEffects();
tick();
expect(store.entities().length).toEqual(2);
expect(store.entities()).toEqual([
{
Expand Down Expand Up @@ -162,6 +163,7 @@ describe('withEntitiesLocalFilter', () => {
patchState(store, setAllEntities(mockProducts));
store.setLoaded();
TestBed.flushEffects();
tick();
expect(store.entities().length).toEqual(2);
expect(store.entities()).toEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
WritableStateSource,
} from '@ngrx/signals';
import {
EntityComputed,
EntityProps,
EntityMap,
EntityState,
NamedEntityComputed,
NamedEntityProps,
NamedEntityState,
SelectEntityId,
} from '@ngrx/signals/entities';
Expand Down Expand Up @@ -110,23 +110,23 @@ export function withEntitiesLocalFilter<
(Collection extends ''
? {
state: EntityState<Entity>;
computed: EntityComputed<Entity>;
props: EntityProps<Entity>;
methods: {};
}
: {
state: NamedEntityState<Entity, Collection>;
computed: NamedEntityComputed<Entity, Collection>;
props: NamedEntityProps<Entity, Collection>;
methods: {};
}),
Collection extends ''
? {
state: EntitiesFilterState<Filter>;
computed: EntitiesFilterComputed;
props: EntitiesFilterComputed;
methods: EntitiesFilterMethods<Filter>;
}
: {
state: NamedEntitiesFilterState<Collection, Filter>;
computed: NamedEntitiesFilterComputed<Collection>;
props: NamedEntitiesFilterComputed<Collection>;
methods: NamedEntitiesFilterMethods<Collection, Filter>;
}
> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
import {
discardPeriodicTasks,
fakeAsync,
flush,
TestBed,
tick,
} from '@angular/core/testing';
import { signalStore, type, withState } from '@ngrx/signals';
import { withEntities } from '@ngrx/signals/entities';
import { of } from 'rxjs';
Expand Down Expand Up @@ -221,10 +227,7 @@ describe('withEntitiesRemoteFilter', () => {
expect(store.entities().length).toEqual(mockProducts.length);
tick(400);
expect(store.entities().length).toEqual(2);
store.filterEntities({
filter: { search: 'zero', foo: 'bar' },
forceLoad: true,
});
expect(store.entitiesFilter()).toEqual({ search: 'zero', foo: 'bar' });
});
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
WritableStateSource,
} from '@ngrx/signals';
import type {
EntityComputed,
EntityProps,
EntityState,
NamedEntityComputed,
NamedEntityProps,
NamedEntityState,
} from '@ngrx/signals/entities';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
Expand Down Expand Up @@ -144,23 +144,23 @@ export function withEntitiesRemoteFilter<
(Collection extends ''
? {
state: EntityState<Entity>;
computed: EntityComputed<Entity>;
props: EntityProps<Entity>;
methods: CallStatusMethods;
}
: {
state: NamedEntityState<Entity, Collection>;
computed: NamedEntityComputed<Entity, Collection>;
props: NamedEntityProps<Entity, Collection>;
methods: NamedCallStatusMethods<Collection>;
}),
Collection extends ''
? {
state: EntitiesFilterState<Filter>;
computed: {};
props: {};
methods: EntitiesRemoteFilterMethods<Filter>;
}
: {
state: NamedEntitiesFilterState<Collection, Filter>;
computed: {};
props: {};
methods: NamedEntitiesRemoteFilterMethods<Collection, Filter>;
}
> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
WritableStateSource,
} from '@ngrx/signals';
import {
EntityComputed,
EntityProps,
EntityState,
NamedEntityComputed,
NamedEntityProps,
NamedEntityState,
SelectEntityId,
setAllEntities,
Expand Down Expand Up @@ -171,13 +171,13 @@ export function withEntitiesLoadingCall<
(Collection extends ''
? {
state: EntityState<Entity> & CallStatusState;
computed: EntityComputed<Entity> & CallStatusComputed<Error>;
props: EntityProps<Entity> & CallStatusComputed<Error>;
methods: CallStatusMethods<Error>;
}
: {
state: NamedEntityState<Entity, Collection> &
NamedCallStatusState<Collection>;
computed: NamedEntityComputed<Entity, Collection> &
props: NamedEntityProps<Entity, Collection> &
NamedCallStatusComputed<Collection, Error>;
methods: NamedCallStatusMethods<Collection, Error>;
}),
Expand Down
Loading
Loading