Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a renderToStream method #61

Closed
karaggeorge opened this issue Mar 29, 2018 · 1 comment
Closed

Add a renderToStream method #61

karaggeorge opened this issue Mar 29, 2018 · 1 comment

Comments

@karaggeorge
Copy link
Contributor

karaggeorge commented Mar 29, 2018

I'm working on a package and I need to render a component temporarily (like renderToString does) but I need the lifecycle events to occur and emit the updates to a stream. However, I don't need the stdin hooks for escape, Ctrl+c etc. Plus, when I call unmount, I don't want the program to exit.

Right now, as a workaround, I call render(<Component />, {stdout, stdin}) with my stdout being the stream I implement, and stdin being a Noop version of a Readable stream made to look like stdin. To unmount, I have to import call-tree directly and manually unmount, since calling the returned method of render ends my process.

I think implementing a method renderToStream that does the basic functionality without being bound to stdin/stdout is fairly easy, and then render could use that, and add the stdin interactions.

If that sounds like a good idea, I can write a PR.
If there is an easier way to do this that I'm not seeing, let me know.

Also, I think it would make sense to be passing the updated component by itself (without the eraseLine characters that the log-update uses to clear the terminal)

@karaggeorge
Copy link
Contributor Author

The purpose of this is a package that allows components to be rendered side-to-side (horizontally aligned):
kapture 2018-03-30 at 0 26 00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant