constructor(options) { super(options); this.LINK = actions.create('LINK', this); if (options && options.data) { // options has `data` attribute: [{name: 'name', value: value},...] options.data.forEach(value => { this[value.name] = value.value; }); this.href = options.href; // TODO - This may cause a name clash! } }
/** Returns a new LIST action. * This is the default action for a Collection+JSON object **/ static get LIST() { return actions.create(actions.LIST.type, this); }
/** Returns a new VIEW_LINK action for `rel`. * This can be dispatched to trigger a link in a Collection+JSON object **/ static viewLink(rel) { return { ...actions.create(actions.VIEW_LINK.type, this), rel, }; }