(
host: ReactiveControllerHost,
task: TaskFunction<T, R> | TaskConfig<T, R>,
args?: ArgsFunction<T>
)
| 234 | args?: ArgsFunction<T> |
| 235 | ); |
| 236 | constructor( |
| 237 | host: ReactiveControllerHost, |
| 238 | task: TaskFunction<T, R> | TaskConfig<T, R>, |
| 239 | args?: ArgsFunction<T> |
| 240 | ) { |
| 241 | (this._host = host).addController(this); |
| 242 | const taskConfig = |
| 243 | typeof task === 'object' ? task : ({task, args} as TaskConfig<T, R>); |
| 244 | this._task = taskConfig.task; |
| 245 | this._argsFn = taskConfig.args; |
| 246 | this._argsEqual = taskConfig.argsEqual ?? shallowArrayEquals; |
| 247 | this._onComplete = taskConfig.onComplete; |
| 248 | this._onError = taskConfig.onError; |
| 249 | this.autoRun = taskConfig.autoRun ?? true; |
| 250 | // Providing initialValue puts the task in COMPLETE state and stores the |
| 251 | // args immediately so it only runs when they change again. |
| 252 | if ('initialValue' in taskConfig) { |
| 253 | this._value = taskConfig.initialValue; |
| 254 | this._status = TaskStatus.COMPLETE; |
| 255 | this._previousArgs = this._getArgs?.(); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | hostUpdate() { |
| 260 | if (this.autoRun === true) { |
nothing calls this directly
no test coverage detected