async
2.1Create a compute that can set its value after the computed function has been called.
can.compute.async(initialValue, computed(currentValue, setValue(newValue) )
Parameters
-
The
{*}initial value of the compute.
-
computed
{can.compute.asyncComputer(lastSetValue, setVal)}A function that returns the current value of the compute and can optionally later call its
setValuecallback to update the value.
Returns
{compute(newVal)}
Returns a compute, but a compute that will possibly not have the correct value unless it is bound to.
Use
The following compute is a live list of todos for a given userId.
todosvalue would alternate betweennulland a Todo.List asuserIdchanges.The following replaces the list in place: