diff options
Diffstat (limited to 'src/thing/album.js')
-rw-r--r-- | src/thing/album.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/thing/album.js b/src/thing/album.js index 1915ab85..be37489d 100644 --- a/src/thing/album.js +++ b/src/thing/album.js @@ -10,7 +10,7 @@ import { } from '../util/sugar.js'; export default class Album extends Thing { - #tracks; + #tracks = []; static updateError = { tracks: Thing.extendPropertyError('tracks') @@ -19,16 +19,20 @@ export default class Album extends Thing { update(source) { withAggregate(({ wrap, call, map }) => { if (source.tracks) { - this.#tracks = map(source.tracks, validateReference('track'), { + this.#tracks = map(source.tracks, t => validateReference('track')(t) && t, { errorClass: this.constructor.updateError.tracks }); } }); } + + get tracks() { return this.#tracks; } } const album = new Album(); +console.log('tracks (before):', album.tracks); + try { album.update({ tracks: [ @@ -41,3 +45,5 @@ try { } catch (error) { showAggregate(error); } + +console.log('tracks (after):', album.tracks); |