Pass-by-reference Detected in State
ZonZonZon opened this issue · 1 comments
ZonZonZon commented
In your article (part 2) there is a State class example:
public class AppState {
public final List todoItems;
public final TodoFilter filter;
public AppState(List<TodoItem> todoItems, TodoFilter filter) {
this.todoItems = todoItems;
this.filter = filter;
}
}
If I'm not mistaken, this will not freeze the state of an app, because passed parameters are references and this.todoItems copies a reference. Thus after some time reference source changes and so does my final this.todoItems.
There should be a kind of clone with a new object creation. Doing it in reducer is not obvious and can be source of errors. State class is a better place to my mind.
ZonZonZon commented
Missed Pcollections part in Prologue. Sorry.