EggingtonE
Windmill6mo ago
2 replies
Eggington

Saving to App State from File Input.

I am trying to create a CSV previewer in the windmill app editor (more steps later that is just step 1)... and I'm thinking my process should be that when a file is uploaded to the "file input" component, a background runnable will update state.csvContent to the decoded csv string, and then my preview text box watches state.csvContent and updates appropriately. The issue i'm encountering is that I can't seem to get state to update.

In my background runnable, I have passed state as an input.
export async function main(csv_file: string, state: any) {
  const decodedBytes = Uint8Array.from(atob(csv_file), c => c.charCodeAt(0));
  const decoder = new TextDecoder("utf-8");
  const csvContent = decoder.decode(decodedBytes);
  console.log(csvContent)
  state.csvContent = csvContent
  console.log(state)
}

here in the background runnable, when logging state it looks good, but in the editor sidebar, it never shows any new values populating to state... and likewise my text box is not rendering anything from state.csvContent
Was this page helpful?