Skip to content

Conversation

@mkremnev
Copy link
Owner

No description provided.

Comment on lines +19 to +20
<Route path="/rules" component={Rules}></Route>
<Route path="/game" component={GameOfLife}></Route>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему тут появились закрывающие теги? зачем?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Странно, сейчас уберу, сами добавились автоматом.

Comment on lines 53 to 56
constructor(props: Timer) {
super(props);
this.timerId = props.timerID as NodeJS.Timeout;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем тебе конструктор? у тебя уже подклчюен плагин для class-properties

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Только разобрался с этим, понял, что не нужно было так делать.

this.timerId = props.timerID as NodeJS.Timeout;
}
onClick = (x: number, y: number) => {
this.props['setFill']({ x, y });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему скобочная нотация? точечная же короче

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Взял из примера, а потом когда разобрался, забыл исправить.

Comment on lines 74 to 68
if (isRunningGame || gameStarted) {
this.timerId = setInterval(() => {
this.props.isGame();
}, speed);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

надеюсь, таймер мы обсудили?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, можно просто его определять, и использовать внутри компонента.

Comment on lines +11 to +22
export function setFill(payload: Coordinates) {
return {
type: SET_CELL,
payload,
};
}

export function clearBoard() {
return {
type: CLEAR_BOARD,
};
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как на счет redux-toolkit?

ну или хотя бы свой хелпер сделать, это же просто куча однотипных действий

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я пробовал предварительно без toolkit, чтобы разобратьтся в общем с Redux. Следующим шагом хотел уже с toolkit сделать.

Comment on lines +50 to +73
const amountAliveNeighbors = (x: number, y: number) => {
const eightNeighbors = [
[-1, -1],
[-1, 0],
[-1, 1],
[0, 1],
[1, 1],
[1, 0],
[1, -1],
[0, -1],
];

return eightNeighbors.reduce((aliveNeighbors, neighbor) => {
const xCell = x + neighbor[0];
const yCell = y + neighbor[1];
const endBoard =
xCell >= 0 &&
xCell < 20 &&
yCell >= 0 &&
yCell < 20;
if (
aliveNeighbors < 4 &&
endBoard &&
prevBoard[xCell][yCell]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошо бы это все вынести в отдельную функцию и покрыть ее тестами

метод должен помещаться на экран - те не больше 25-35 строк

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласен, сделаю.

@mkremnev mkremnev force-pushed the master branch 2 times, most recently from 0135b35 to 845a24b Compare September 20, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants