I have the following attempt at a reducer
import { ActionReducer, Action, Store } from '@ngrx/store';
import { Observable } from 'rxjs'
import { Name } from './name.model'
export const ADD_NAME = 'ADD_NAME';
export const name: ActionReducer<any> = ( state = new Name(), action: Action ) => {
switch ( action.type ) {
case ADD_NAME:
return [ state, action.payload ];
default:
return state;
}
};
I would like to store a Name instance in the Store. Currently the ADD_NAME returns an array. How can I store just a single instance instead of array
You can write this with typescript 2.1+:
or