Hey there! In integrating Mobiscroll into our product, we’ve notice that the calendar component mutates the passed object if it is missing Mobilscroll’s internal _id
attribute: the calendar adds the ID parameter.
Is it possible (nothing in docs) to either:
- Direct Mobiscroll to not mutate an object?
- Specify the name (we use
id
) of the employed attribute?
Mutation of objects in a manner that can propagate backwards through the rest of the application is undesirable behaviour, as would be adding an object attribute for the use of a proprietary presentation plugin.
Immutability is a big part of what we strive for within our product.
Our model instantiation for calendar events appears thus:
export class Event extends Model {
readonly color: string;
readonly end: Date;
readonly id: number;
readonly start: Date;
readonly text: string;
readonly type: EventType;
constructor(input: Event) {
super(input);
}
}
export abstract class Model {
constructor(input?: object) {
Object.assign(this, input);
Object.freeze(this);
}
}