Project#solve#
Schedules a Project and accepts the scheduled dates as its baseline. Pass a ProjectData object to load a project, or null to reschedule after apply. preview, loadProfile, evaluate, slots and suggestAssignments need a solved project.
For a one-shot run without keeping state, use schedule.
Signature#
data: ProjectData | null, options?: SolveOptions: ScheduleResult
Synchronous. Runs on the calling thread.
Parameters#
| Name | Type | Description |
|---|---|---|
data |
ProjectData | null |
Replacement data, or null to schedule the current state. undefined is treated as null. Never mutated. |
options |
SolveOptions |
Optional. Subtree, analytics and reporting switches. Default {}. |
Behavior#
- With
data, the call validates the replacement data, installs it, schedules it and accepts the result. The previous data is discarded. Howdatais validated or repaired depends on the project'svalidationoption (seeProject). - With
null, the call schedules the current state when it has unsolved edits. When the project is already solved with equaloptions, it returns the cached result without scheduling again. The cache key is the wholeoptionsobject.
Tasks touched by successful apply calls since the last solve appear in updates as direct updates, even when the planner leaves them where the edit put them. A cyclic project returns unchanged dates and keeps those tasks pending.
The result's baselineId names the accepted baseline. It changes only when the data or the dates change, so solving an unchanged state keeps it.
Returns#
A ScheduleResult. Each call returns a fresh object that shares nothing with data or the project, including a cached result. Date fields are strings, or local Date objects when the project was created with dates: "date".
Errors#
| Error | When |
|---|---|
InputError |
data or options fails parsing or validation; kind, message and path describe the problem. Also thrown for a non-finite number or an invalid Date in the input. The previous state and cached result are kept. |
ProjectError "needs-resync" |
data is null after an apply rejected an operation and no solve(data) followed |
TypeError |
The input has a circular reference or a BigInt. |
Error("Project has been disposed") |
The project was disposed with dispose. |
Example#
Load a project, commit an edit and reschedule it.
const = new;
const = ;
// Nothing changed: the cached result comes back with the same baselineId.
const = ;
; // true
;
const = ;
Related#
Project- the class and its other methodsSolveOptions- the optionsScheduleResult- the returned result- Errors -
InputErrorandProjectError - Scheduling a Project - loading, caching and solve options