* Views content. * @param {Chain} content * @return {Promise} Resolves when completed.
(content)
| 21 | * @return {Promise} Resolves when completed. |
| 22 | */ |
| 23 | async view (content) { |
| 24 | try { |
| 25 | // check for invalid settings |
| 26 | const invalidSettings = this.getSettingsForm().getInvalidFields() |
| 27 | if (invalidSettings.length > 0) { |
| 28 | throw new InvalidInputError( |
| 29 | 'Can\'t view content with invalid settings: ' + |
| 30 | invalidSettings.map(setting => setting.getLabel()).join(', ')) |
| 31 | } |
| 32 | |
| 33 | if (!this.hasView()) { |
| 34 | // run view as soon as the view is being created |
| 35 | this._queuedContent = content |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | // perform actual view |
| 40 | content = await this.willView(content) |
| 41 | await this.performView(content) |
| 42 | await this.didView(content) |
| 43 | |
| 44 | // clear error |
| 45 | if (this._error !== null) { |
| 46 | this._error = null |
| 47 | this.updateView() |
| 48 | } |
| 49 | } catch (error) { |
| 50 | this._error = error |
| 51 | this.updateView() |
| 52 | throw error |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Triggered before performing view of given content. |
no test coverage detected