Code Monkey home page Code Monkey logo

Comments (5)

VldMrgnn avatar VldMrgnn commented on June 18, 2024 1

from redux-saga.

Codex101 avatar Codex101 commented on June 18, 2024

After thinking about it, I don't think it's really possible for not only redux saga, but most of the recommended side-effect managers. Something about how it's not really the common workflow.

from redux-saga.

neurosnap avatar neurosnap commented on June 18, 2024

Greetings! The example you provided looked pretty good to me, what about it doesn't work for your needs?

from redux-saga.

Codex101 avatar Codex101 commented on June 18, 2024

Greetings! The example you provided looked pretty good to me, what about it doesn't work for your needs?

Don't think you can dynamically assign the cancel string right?
yield take('CANCEL_TASK_{ID}')

So if I called the below, it wouldn't auto map the request to the cancelled task.

    dispatch({type: 'REQUEST_123'})
    dispatch({type: 'CANCEL_TASK_123'})

from redux-saga.

Codex101 avatar Codex101 commented on June 18, 2024

Hello from a fellow developer. When I have to cancel a specific task, I usually use a Map Object to keep record of the tasks. Then if needed I make sure to find that individual task and cancel. You can find a naive example but similar to your case here: https://codesandbox.io/s/redux-saga-cancel-task-76ufws?file=/src/App.tsx I hope it helps. Regards, Vlad De la: Codex101 @.> Trimis: joi, 30 martie 2023 08:46 Către: redux-saga/redux-saga @.> Cc: Subscribed @.> Subiect: [redux-saga/redux-saga] Is it possible to selectively cancel tasks in an actionChannel? Ie cancel the 3rd task out of 5 running ones. (Issue #2374) Description Is it possible to cancel the ith running async API task with redux saga? For instance, my task is postApiData(data) and a user calls that a few times, just with different data posted. I was using React-Thunk to call APIs async, but now I need to call APIs AND cancel any running API call if the user cancels the queued API task. The current cancel example https://redux-saga.js.org/docs/advanced/TaskCancellation , and most of what I've found online focus on a single primary/main task to cancel. Hypothetically, it'd be something like function watchRequests() { while (true) { const {payload} = yield take('REQUEST') const task = yield fork(handleRequest, payload) // Where {ID} is the unique passed ID to track the event, and thus trigger a frontend action when the user click's that item. yield take('CANCEL_TASK_{ID}') yield cancel(task) } } function handleRequest(payload) { ... } — Reply to this email directly, view it on GitHub <#2374> , or unsubscribe https://github.com/notifications/unsubscribe-auth/ANFOKQ4X5PKHZ2J6IY36J2TW6UMZJANCNFSM6AAAAAAWMZGNQU . You are receiving this because you are subscribed to this thread. https://github.com/notifications/beacon/ANFOKQ2OLW6ATGQU3MOFGB3W6UMZJA5CNFSM6AAAAAAWMZGNQWWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHGEKUM3E.gif Message ID: @.** @.***> >

Was hoping could avoid the manual queue system implemention, but, it doesn't seem possible. Thanks for the solution :)

from redux-saga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.