Redirect to newly added keymap

This commit is contained in:
NejcZdovc
2016-11-17 08:56:40 +01:00
committed by József Farkas
parent d2d69ae52d
commit 0383c50dbc

View File

@@ -10,9 +10,20 @@ import 'rxjs/add/operator/withLatestFrom';
import { KeymapActions } from '../actions';
import { AppState } from '../index';
import { Keymap } from '../../config-serializer/config-items/Keymap';
@Injectable()
export class KeymapEffects {
@Effect({ dispatch: false })add$: any = this.actions$
.ofType(KeymapActions.ADD)
.withLatestFrom(this.store)
.do((latest) => {
const state: AppState = latest[1];
const entities: Keymap[] = state.keymaps.entities;
this.router.navigate(['/keymap', entities[entities.length - 1].abbreviation]);
});
@Effect({ dispatch: false })remove$: any = this.actions$
.ofType(KeymapActions.REMOVE)
.withLatestFrom(this.store)