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

_.of and asyncify #519

Closed
svozza opened this issue Aug 5, 2016 · 6 comments
Closed

_.of and asyncify #519

svozza opened this issue Aug 5, 2016 · 6 comments

Comments

@svozza
Copy link
Collaborator

svozza commented Aug 5, 2016

I find myself reaching for this function a lot, especially in functional pipelines where I currently have to break into a lambda to convert a value into a stream:

const pipeline = hl.compose(hl.flatMap(func3), x => hl([x]), func2, func1);

I remember it was actually implemented ages ago in #114 but was part of a larger piece of work to bring Fantasyland compatibility. @quarterto Would you mind if I stole your implementation and tests for a PR? The reason I'm raising this issue is because @megawac suggestion, if I understand it correctly, made me think how trivial it would be to make synchronous functions asynchronous.

const asyncSyncFunc = hl.compose(hl.of, someSyncFunc);
@vqvu
Copy link
Collaborator

vqvu commented Aug 6, 2016

how trivial it would be to make synchronous functions asynchronous.

A proper asyncify would need to catch errors, I think, which simply composing _.of wouldn't do.

@svozza
Copy link
Collaborator Author

svozza commented Aug 6, 2016

Ah good point, guess you'd need to go down the generator route then.

@vqvu
Copy link
Collaborator

vqvu commented Aug 6, 2016

I'm still +1 for _.of though. I use it all the time too. Right now, I just have it implemented locally in my code. It would be nice to have direct support in the library.

It would also be nice to have _.fromError or extend _() to accept Error. Sometimes it's useful to create a stream that only emits an error.

@svozza
Copy link
Collaborator Author

svozza commented Aug 6, 2016

Yeah, good call on fromError I often hand roll that one too. I'm leaning towards an explicit function rather than rolling it into the constructor but I'm open to persuasion.

@vqvu
Copy link
Collaborator

vqvu commented Aug 6, 2016

I prefer the explicit function too.

On Aug 6, 2016 11:54 AM, "Stefano Vozza" notifications@github.com wrote:

Yeah, good call on fromError I often hand roll that one too. I'm leaning
towards an explicit function rather than rolling it into the constructor
but I'm open to persuasion.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#519 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGIyZcPEdF-0qtTQ6Vz8cGpmfvgpnY6Kks5qdLxXgaJpZM4Jd6_x
.

@svozza
Copy link
Collaborator Author

svozza commented Aug 6, 2016

Cool. I'll do that then.

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

2 participants