I am looking at some legacy code and they have created all the redux reducers as instance methods of a class:
@Injectable()
export class PeopleActions {
constructor(private ngRedux: NgRedux<any>) {}
add() {
this.ngRedux.dispatch({ADD, payload: {foo: 'bar;});
}
remove() {
this.ngRedux.dispatch({Remove, payload: {foo: 'bar;});
}
// etc.
I would normally create these as sepreate functions
export function add { // etc.}
export function remove { // etc.}
And then create a union:
type MyActions = add | remove;
Can I somehow create a union of the class instance methods?
If you want a union of all keys in the type you can use
keyof
If the class also has public fields that are not methods and you want to filter those out you can use a conditional type: