fix(core): update
This commit is contained in:
parent
a4d43456d7
commit
c5a3eb63ad
@ -39,11 +39,11 @@ tap.test('should select something', async () => {
|
|||||||
tap.test('should dispatch a state action', async () => {
|
tap.test('should dispatch a state action', async () => {
|
||||||
const addFavourite = testStatePart.createAction<string>(async (statePart, payload) => {
|
const addFavourite = testStatePart.createAction<string>(async (statePart, payload) => {
|
||||||
const currentState = statePart.getState();
|
const currentState = statePart.getState();
|
||||||
currentState.currentFavorites.push(payload)
|
currentState.currentFavorites.push(payload);
|
||||||
return currentState;
|
return currentState;
|
||||||
});
|
});
|
||||||
await testStatePart.dispatchAction(addFavourite, 'my favourite things')
|
await testStatePart.dispatchAction(addFavourite, 'my favourite things');
|
||||||
expect(testStatePart.getState().currentFavorites).to.include('my favourite things')
|
expect(testStatePart.getState().currentFavorites).to.include('my favourite things');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -2,7 +2,7 @@ import * as plugins from './smartstate.plugins';
|
|||||||
import { StatePart } from './smartstate.classes.statepart';
|
import { StatePart } from './smartstate.classes.statepart';
|
||||||
|
|
||||||
export interface IActionDef<TStateType, TActionPayloadType> {
|
export interface IActionDef<TStateType, TActionPayloadType> {
|
||||||
(stateArg: StatePart<any, TStateType>, actionPayload: TActionPayloadType): Promise<TStateType>;
|
(stateArg: StatePart<any, TStateType>, actionPayload: TActionPayloadType): Promise<TStateType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,9 @@ export class StatePart<TStatePartName, TStatePayload> {
|
|||||||
/**
|
/**
|
||||||
* creates an action capable of modifying the state
|
* creates an action capable of modifying the state
|
||||||
*/
|
*/
|
||||||
createAction <TActionPayload>(actionDef: IActionDef<TStatePayload, TActionPayload>): StateAction<TStatePayload, TActionPayload> {
|
createAction<TActionPayload>(
|
||||||
|
actionDef: IActionDef<TStatePayload, TActionPayload>
|
||||||
|
): StateAction<TStatePayload, TActionPayload> {
|
||||||
return new StateAction(actionDef);
|
return new StateAction(actionDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user