[reference: ComputedRef<T | undefined>, triggerUpdate: () => void]
const path = ref("/tmp");
const listDirectory = () =>
server.execute(new Command(["ls", path.value])).map((proc) => proc.getStdout().trim().split(RegexSnippets.newlineSplitter))
const [dirContents, refetchDirContents] = computedResult(listDirectory);
// dirContents automatically refreshes whenever path changes, or when refetchDirContents() is called
// dirContents.value is undefined until listDirectory() finishes
Create a computed ref with default value that grabs it's value from a Result or ResultAsync, returning computed ref and a manual update trigger function.
[reference: ComputedRef<T>, triggerUpdate: typeof getter]
const path = ref("/tmp");
const listDirectory = () =>
server.execute(new Command(["ls", path.value])).map((proc) => proc.getStdout().trim().split(RegexSnippets.newlineSplitter))
const [dirContents, refetchDirContents] = computedResult(listDirectory, []);
// dirContents automatically refreshes whenever path changes, or when refetchDirContents() is called
// dirContents.value defaults to [] until listDirectory() finishes
Create a computed ref that grabs it's value from a Result or ResultAsync, returning computed ref and a manual update trigger function.