work on streamer

This commit is contained in:
bkfox
2019-09-21 17:44:23 +02:00
parent d3f39c5ade
commit cbfd1c1449
2 changed files with 10 additions and 8 deletions

View File

@ -19,6 +19,7 @@ export function getCsrf() {
// TODO: move in another module for reuse
// TODO: prevent duplicate simple fetch
export default class Model {
constructor(data, {url=null}={}) {
this.commit(data);
@ -100,7 +101,7 @@ export default class Model {
return index == -1 ? null : this.data[attr][index];
}
static updateList(list=[], old=[]) {
static updateList(list=[], old=[], ...initArgs) {
return list.reduce((items, data) => {
const id = this.getId(data);
let [index, obj] = [old.findIndex(o => o.id == id), null];
@ -109,7 +110,7 @@ export default class Model {
items.push(old[index]);
}
else
items.push(new this(data))
items.push(new this(data, ...initArgs))
return items;
}, [])
}