Reputation: 4538
I know NgRx loves plain objects in the state, but why not this kind of one?
export class EventRecord {
Id = -1;
Title = "";
private occurred?: string = undefined;
get OccurredDate(): string {
return this.occurred ? this.occurred : "";
}
set OccurredDate(value: string) {
const mValues = moment(value);
if (mValues.isValid()) {
this.occurred = mValues.toISOString();
} else {
throw Error("Invalid date value");
}
}
PictureUri?: string;
}
what's not serializable here?
Upvotes: 1
Views: 1378
Reputation: 1395
I think the problem is that you can't serialize a class that also has behaviour attached (the getter and setter). You can only serialize pure data class (classes without behaviour, with only plain properties).
Upvotes: 4