forked from angular-architects/ngrx-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve tree shaking for with-pagination
- Loading branch information
1 parent
695461c
commit ad09e31
Showing
3 changed files
with
54 additions
and
126 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
27 changes: 19 additions & 8 deletions
27
apps/demo/src/app/flight-search-with-pagination/flight-store.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 |
---|---|---|
@@ -1,30 +1,41 @@ | ||
import { FlightService } from '../shared/flight.service'; | ||
|
||
import { signalStore, type } from '@ngrx/signals'; | ||
|
||
import { patchState, signalStore, type, withMethods } from '@ngrx/signals'; | ||
import { withEntities } from '@ngrx/signals/entities'; | ||
import { | ||
withCallState, | ||
withDataService, | ||
withPagination, | ||
setPageSize, | ||
gotoPage, | ||
} from '@angular-architects/ngrx-toolkit'; | ||
import { Flight } from '../shared/flight'; | ||
|
||
// Name of the collection | ||
const collectionName = 'flight'; | ||
|
||
export const FlightBookingStore = signalStore( | ||
withCallState({ | ||
collection: 'flight', | ||
collection: collectionName, | ||
}), | ||
withEntities({ | ||
entity: type<Flight>(), | ||
collection: 'flight', | ||
collection: collectionName, | ||
}), | ||
withDataService({ | ||
dataServiceType: FlightService, | ||
filter: { from: 'Wien', to: '' }, | ||
collection: 'flight', | ||
collection: collectionName, | ||
}), | ||
withPagination({ | ||
entity: type<Flight>(), | ||
collection: 'flight', | ||
}) | ||
collection: collectionName, | ||
}), | ||
withMethods((store) => ({ | ||
setFlightPageSize: (size: number) => { | ||
patchState(store, setPageSize(size, { collection: collectionName })); | ||
}, | ||
gotoFlightPage: (page: number) => { | ||
patchState(store, gotoPage(page, { collection: collectionName })); | ||
}, | ||
})) | ||
); |
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