M
const newRecordsSource = merge(
of(records),
newRecord
).pipe(
scan((acc: AnswerRow[], currentValue: AnswerRow) => {
if (Array.isArray(currentValue)) {
return acc;
}
const newRecords = acc
.map((record) => {
if (!!currentValue && record.id === currentValue.id) {
return currentValue;
}
return record;
});
return newRecords;
}),
);