reflex-frp / reflex-process

Run and interact with system processes from within a Reflex FRP application.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

Support use-cases that do not translate handles to events #8

Open lspitzner opened 4 years ago

lspitzner commented 4 years ago

Two examples:

1) You want to start a process with static blob as stdin. In that case, you can use createRedirectedProcess, pass never as the input event but simply do the writing of the blob in the stdin-thread-initializer (called "handlers" here, although that is a bit confusing terminology in FRP context). The user needs to take care to fork the action that does the writing too, because it may block, and the initializer is run lifted into the network, so would block the network. This is awkward. 2) You want to pipe stdout from one process to stdin from another, without going through the network. Sure, you could take the stdout event and pass it as the stdin event, but this needlessly keeps the network busy. I am not sure if you could pass the stdout pipe created from the first process as a UseHandle when creating the second (hard to find documentation around this).

The only way I see to support such use-cases would be to expose more of the underlying process constructs. Although this might be out-of-scope for a library that is about reflex integration, maybe we can put this in an "internal" module.

I have started on a draft interface that supports the first use-case. I'll try to turn it into a PR sometime, feel free to ping me if I haven't yet and are interested in this.

3noch commented 4 years ago

Point 1 would be solved by #9. Point 2 is a good idea! Please feel free to contribute a PR to this effect.