Skip to content
This repository has been archived by the owner on Sep 17, 2020. It is now read-only.

Join forces with use-task #2

Open
alexlafroscia opened this issue Jun 12, 2019 · 2 comments
Open

Join forces with use-task #2

alexlafroscia opened this issue Jun 12, 2019 · 2 comments

Comments

@alexlafroscia
Copy link

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project
    [x] none of the above

Hello!

I created use-task which, I think, is intending to solve the same use-case as this library. Generators, based on ember-concurrency, React hooks, etc.

Unfortunately a lot has some up since I started the project and I can't give it the kind of attention that I believe the idea deserves.

Would you be interested at all on collaborating on a single library? If anything, I would be pretty happy to give the use-task NPM package name to this project instead, and maybe we can talk a bit about some of the stuff I did supporting AbortController for cancellation.

If you're not interested, no big deal, but if you are I'd love to chat!

@davidgovea
Copy link
Owner

davidgovea commented Jun 14, 2019

Hah! How about that! I promise I searched before creating :)

use-task looks very nice! I've been wanting ember-concurrency in react for the last year, and just "got access" to hooks (been using RN, not web). Nice work with the progress-bar demos 👍

Went through some of the discussions in the repo -- some good considerations in there. Also going through the code & AbortController work. Haven't really used AbortController yet, but it was just added to the frisbee fetch library, so I'll be playing with it soon. I've probably abandoned a lot of poor requests in cancelled ember-concurrency tasks.. 😕 😛

I'm still waffling a bit with the use of posterus and its place here. Considering going all-in on Futures, or alternately hiding it completely from users. Stepping through a generator doesn't look too hard, so maybe I even drop it..? Need to see if the unique features like upstream cancellation & Rustic approach are useful for this lib. The primitive is very handy & well-designed -- ember-concurrency and redux-saga both ship their own versions of race / all, which is already handled.

I haven't had the time to actually use this for real yet; I think a lot of learning will come from that.

Have you been using use-task? Any observations on the ergonomics?
It looks pretty mature.. (maybe just missing maxConcurrency? - I pretty much just lifted p-limit)
Intrigued by what's on your radar (or what would be, given more time).

On the whole though, definitely in support of collaboration/consolidation. Chatting here is fine, but also feel free to hit me up @ email on commits, or keybase,etc
Thanks for reaching out!

@alexlafroscia
Copy link
Author

posterus is interesting -- I've never come across that before. I ended up writing my own generator consumption code (it isn't too hard, actually) since that gave me a lot of control over how to handle things.

We're actually not using use-task yet either! The main use-case we imagined was handling form submission, since that's what we do in Ember, but we currently are using Formik instead which handles giving us the pending state (etc) rather than needing this lower-level primitive.

As far as maxConcurrency goes I made some intentional omissions from the Ember Concurrency configuration for an initial release. I may support that one but honestly may not -- I've never needed in in Ember Concurrency and would rather wait for someone to ask for it than support a feature we don't need!

I (somewhat) recently did some work with AbortController just to make a TaskInstance cancellable in a way that was in line with the platform's cancellation primitive. What's also neat is that you can get access to the AbortController signal within the task, which allows you to thread it through to a fetch call or something similar. This allows you to actually abort a fetch when a task is cancelled, rather than letter it complete and then ignoring the result.

As far as future stuff, I wanted to make something like useTaskEffect that was essentially useEffect but leveraging a generator instead. I honestly have no idea when or if I'm ever going to get to it though -- I'm currently in "job search" mode and overall kind of burnt out on open-source.

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

No branches or pull requests

2 participants