@brightspace-ui/labs
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -57,3 +57,3 @@ { | ||
}, | ||
"version": "2.3.0" | ||
"version": "2.4.0" | ||
} |
@@ -22,2 +22,3 @@ # d2l-labs-attribute-picker | ||
| `invalid-tooltip-text` | String (default: At least one attribute must be set) | The text that will appear in the tooltip that informs a user that the state is invalid | | ||
| `label` | String, Required | The label associated with the attribute picker for screen reader users | | ||
| `limit` | Number | The maximum length of attribute-list permitted | | ||
@@ -24,0 +25,0 @@ | `required` | Boolean | When true, an error state will appear if no attributes are set. Error state only appear once the user interacts with the component. | |
@@ -69,3 +69,18 @@ export const ASYNC_STATUSES = Object.freeze({ | ||
asyncRender(renderStates = {}) { | ||
switch (this.asyncStatus) { | ||
case ASYNC_STATUSES.SUCCESS: | ||
return renderStates[ASYNC_STATUSES.SUCCESS]?.(this.value); | ||
case ASYNC_STATUSES.ERROR: | ||
return renderStates[ASYNC_STATUSES.ERROR]?.(this.error); | ||
case ASYNC_STATUSES.PENDING: | ||
return renderStates[ASYNC_STATUSES.PENDING]?.(); | ||
} | ||
} | ||
hostUpdate() { | ||
this.tryUpdate(); | ||
} | ||
tryUpdate() { | ||
const currDependencies = this._getDependencies(); | ||
@@ -75,5 +90,6 @@ const shouldCompute = this._shouldCompute(this._prevDependencies, currDependencies); | ||
if (shouldCompute) { | ||
this._updateValue(currDependencies); | ||
} | ||
if (!shouldCompute) return false; | ||
this._updateValue(currDependencies); | ||
return true; | ||
} | ||
@@ -80,0 +96,0 @@ |
@@ -5,2 +5,3 @@ import ComputedValue from './computed-value.js'; | ||
constructor(host, valuesOptions = []) { | ||
this._valuesOptions = valuesOptions; | ||
valuesOptions.forEach(({ Controller = ComputedValue, name, ...options }) => { | ||
@@ -10,2 +11,6 @@ this[name] = new Controller(host, options); | ||
} | ||
tryUpdate() { | ||
this._valuesOptions.forEach(({ name }) => this[name].tryUpdate()); | ||
} | ||
} |
@@ -140,2 +140,6 @@ # ComputedValues Controller | ||
### `tryUpdate()` | ||
This method calls the `tryUpdate()` method for each of its computed values in order. See the `ComputedValue` Instance Methods section below for more details. | ||
## `ComputedValues` Instance Members | ||
@@ -149,3 +153,3 @@ | ||
### Constructor | ||
### `constructor(host, options)` | ||
@@ -163,2 +167,21 @@ | Parameter Name | Type | Description | Required | | ||
### `asyncRender(renderMap)` | ||
This method is used to render different things depending on the async state of the computed value. If the computed value is not async, this method will always return `undefined`. | ||
| Parameter Name | Type | Description | Required | | ||
|---|---|---|---| | ||
| `renderMap` | Object | This object must contain different functions to call depending on the async state of the computed value. | Yes | | ||
| `renderMap.pending` | Function() : Any | If the current async state of the computed value is "pending", this function is called when calling `asyncRender`. The function is passed no arguments, and the return value from it is returned from `asyncRender`. | No | | ||
| `renderMap.success` | Function(Any) : Any | If the current async state of the computed value is "success", this function is called when calling `asyncRender`. The function is passed the result of the computed value as its first arguement, and the return value from it is returned from `asyncRender`. | No | | ||
| `renderMap.success` | Function(Any) : Any | If the current async state of the computed value is "error", this function is called when calling `asyncRender`. The function is passed the result of the error value as its first arguement, and the return value from it is returned from `asyncRender`. | No | | ||
### `tryUpdate()` | ||
This method checks if the dependencies have changed since it was last called and runs the compute process if they have. It is called automatically by the controller in between the `willUpdate` and `render` steps of the host's render cycle. | ||
There is normally no need to explicitly call this method since it's automatically called as part of the host's render cycle. However, calling this yourself might be useful if you wish to have the compute process run earlier than it normally would (e.g. during `willUpdate`) in order to make use the resulting value before getting to the render step. | ||
This method takes no arguments and returns `true` if it detected that the dependencies changed and ran the compute process. | ||
## `ComputedValue` Instance Members | ||
@@ -165,0 +188,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220561
3297