diff --git a/libs/ngrx-toolkit/src/lib/with-redux.spec.ts b/libs/ngrx-toolkit/src/lib/with-redux.spec.ts index 1267052..9460bb6 100644 --- a/libs/ngrx-toolkit/src/lib/with-redux.spec.ts +++ b/libs/ngrx-toolkit/src/lib/with-redux.spec.ts @@ -12,7 +12,6 @@ import { HttpTestingController, provideHttpClientTesting, } from '@angular/common/http/testing'; -import { Action } from 'ngrx-toolkit'; interface Flight { id: number; @@ -99,6 +98,27 @@ describe('with redux', () => { }); }); + it('should allow a noPayload action to call without parameters', () => { + const FlightsStore = signalStore( + withState({ flights: [] as Flight[] }), + withRedux({ + actions: { + init: noPayload, + }, + reducer() {}, + effects() { + return {}; + }, + }), + ); + + const flightStore = TestBed.configureTestingModule({ + providers: [FlightsStore], + }).inject(FlightsStore); + + flightStore.init(); + }); + it('should allow multiple effects listening to the same action', () => { const FlightsStore = signalStore( withState({ flights: [] as Flight[], effect1: false, effect2: false }), @@ -134,7 +154,7 @@ describe('with redux', () => { providers: [FlightsStore], }).inject(FlightsStore); - flightStore.init({}); + flightStore.init(); expect(flightStore.effect1()).toBe(true); expect(flightStore.effect2()).toBe(true); diff --git a/libs/ngrx-toolkit/src/lib/with-redux.ts b/libs/ngrx-toolkit/src/lib/with-redux.ts index c73c5f5..8676682 100644 --- a/libs/ngrx-toolkit/src/lib/with-redux.ts +++ b/libs/ngrx-toolkit/src/lib/with-redux.ts @@ -23,9 +23,13 @@ type ActionFns = Record; export type ActionsFnSpecs = Record; type ActionFnCreator = { - [ActionName in keyof Spec]: (( - payload: Spec[ActionName], - ) => Spec[ActionName] & { type: ActionName }) & { type: ActionName & string }; + [ActionName in keyof Spec]: (Record extends Spec[ActionName] + ? () => Spec[ActionName] & { type: ActionName } + : ( + payload: Spec[ActionName], + ) => Spec[ActionName] & { type: ActionName }) & { + type: ActionName & string; + }; }; type ActionFnPayload = Action extends (payload: infer Payload) => void @@ -262,7 +266,7 @@ export function withRedux< EmptyFeatureResult & { methods: PublicStoreActionFns } > { return (store) => { - const { methods, subscriptions } = processRedux( + const { methods } = processRedux( redux.actions, redux.reducer as ReducerFactory, redux.effects as EffectsFactory,