XMLWriter (Reactive) fails to create new file on first time

hello, looks like a bug to me, but can be also bad way of using XMLWriter.
I am using FileDialog (Save) in combination with XMLWriter (Reactive) in order to save files from my app.

I noticed that I have to execute - trigger the process at least twice in order to create my new file.

SaveXML_Reactive.vl (7.9 KB)

Hey

Here’s the improved version

SaveXML_Reactive.vl (7.4 KB)

The problem here is really kinda by design of the reactive writer nodes: in your patch the order of execution between the XMLWriters path input and its data input is not defined. so it happens that the observable is executed first, and only then the path is available. that’s why it then works on the second attempt.

solutions:

  • either framedelay the OK output of the FileDialog
  • or use an AsynTask that does the Serialization and file-writing using the non-reactive writer node

@yar your version only “works” because it also introduces kind of a delay but it’s still a bit wonky.

2 Likes

@joreg I am glad I had my reservations for doing something wrong. But what is the difference from what @yar is proposing in the async approach?
To have a managed region instead?

Correction
Ah! Ok, NON reactive node. I see!

@joreg thank you
Actually better version should look like this:

1 Like

exactly.

1 Like

Thank you both, it is clear now!