Skip to content

[labs/task] Allow setting initial data #2367

@mohe2015

Description

@mohe2015

Description

If you do navigation preloading or similar you may already have the data for the task at component creation time. Then it would make sense to be able to either set that data manually at Task creation time or using some attributes.

The simplest but probably also most unclean change would be to make _value

private _value?: R;

public and name it value

Steps to Reproduce

import {Task} from '@lit-labs/task';

this._apiTask = new Task(
  this,
  taskFunction,
  () => /** @type {[URLSearchParams]} */ ([this.history.url.searchParams])
);
 if (this.initial !== undefined) {
  this._apiTask.status = TaskStatus.COMPLETE;
  // TODO FIXME don't use this private attribute that got minified
  this._apiTask.P = this.initial;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions