0
にReduxのストアを作成することができません。私のモデルであります私の減速機ですは私angualar2アプリケーションここ</p> <p>で不変のjsとReduxの実装しようとしていますangular2
import { List } from 'immutable';
import { TodoModel, ITodoAction } from '../model/todo.model';
export const todoReducer = (state: List<TodoModel>, action: ITodoAction) => {
switch (action.type) {
case 'ADD_TODO':
return state.push(action.todo);
case 'REMOVE_TODO':
return state.delete(findIndexById());
case 'UPDATE_TODO':
return state.update(findIndexById(), (todo) => {
return {
id: todo.id,
text: todo.text,
isCompleted: todo.isCompleted
};
});
case 'TOGGLE_TODO':
return state.update(findIndexById(), (todo) => {
return {
id: todo.id,
text: todo.text,
isCompleted: !todo.isCompleted
};
});
default:
return state;
}
function findIndexById() {
return state.findIndex((todo) => todo.id === action.todo.id);
}
};
は、ここで、ここで私が使用ストア
import { Component, OnInit } from '@angular/core';
import { TodoStore } from '../../common/store/todo.store';
@Component({
selector: 'app-todo',
templateUrl: './todo.component.html',
styleUrls: ['./todo.component.css']
})
export class TodoComponent implements OnInit {
// todo: TodoModel;
constructor(private store: TodoStore) {
// this.todo = new TodoModel();
}
ngOnInit() {
}
}
を持っているしかし、私は自分のアプリケーションを実行すると、私はエラーを得た上で、私のコンポーネントである私の店
import { List } from 'immutable';
import { createStore } from 'redux';
import { ITodoAction, TodoModel } from '../model/todo.model';
import { todoReducer } from '../reducer/todo.reducer';
export class TodoStore {
store = createStore(todoReducer);
get todos(): Array<TodoModel> {
return this.store.getState().toJS();
}
dispatch(action: ITodoAction) {
this.store.dispatch(action);
}
}
ある
Module build failed: Error: F:/Tutorial/angular2/ngTutorial/src/app/common/store/todo.store.ts (7,5): Public property 'store
' of exported class has or is using name 'Store' from external module "F:/Tutorial/angular2/ngTutorial/node_modules/redux/in
dex" but cannot be named.)
私はここに何が欠けているかわかりません、それを稼働させるのを助けてください..