An input is being executed first and so the value of this._settings is still null as to leave asynchronously so that you first execute the settings and then execute the data
edit: If I apply a timeout on the data even if it is with value 1 it will work normally
// should be the first
@Input()
public set settings(value) {
if (value) {
this._settings = Object.assign(this.defaultSettings, value);
} else {
this._settings = Object.assign(this.defaultSettings);
}
}
@Input()
public set data(value: Array<any>) {
if (!value) {
this._data = [];
} else {
this._data = value.map((item: any) =>
typeof item === 'string' || typeof item === 'number'
? new ListItem(item)
: new ListItem({
id: item[this._settings.idField],
text: item[this._settings.textField],
})
);
}
}
Thank you for your help
async awaitonsetters, maybe you should look into thengOnChangeslifecycle hook. It's a hook that runs every time an@Input()changes. And I am sure you can doasync awaitthere.ngOnInitand let the inputs just be simple atomic setters/getters.