Code Monkey home page Code Monkey logo

Comments (3)

neurosnap avatar neurosnap commented on June 9, 2024 1

Hi! Thanks so much for reaching out.

First and foremost: redux-saga is in a stable state and as such backwards compatibility is our primary directive. If you can implement the ability to change debounce -- and throttle -- in a non-breaking way, I'd be happy to review and approve.

I'm also happy to answer any questions you have.

from redux-saga.

neurosnap avatar neurosnap commented on June 9, 2024 1

Hi! You are welcome to just focus on debounce for now if that makes things simpler for you.

from redux-saga.

ensconced avatar ensconced commented on June 9, 2024

I made a start on this. It seems straightforward enough for debounce - my initial attempt at that is here (work in progress) but throttle is a little trickier.

I think the current implementation of throttle would correspond to the leading: true, trailing: true case. For the leading, true, trailing: false case, I think it's as simple as just using buffers.none() instead of buffers.sliding(1)). And leading: false, trailing: false should be simple too (since it basically does nothing).

However, I'm not sure how to approach the leading: false, trailing: true case for throttle.
I wanted to use an fsm like this:

fsmIterator(
  {
    q1() {
      const yActionChannel = { done: false, value: actionChannel(patternOrChannel, buffers.sliding(1)) }
      return { nextState: 'q2', effect: yActionChannel, stateUpdater: setChannel }
    },
    q2() {
      return { nextState: 'q3', effect: yTake(), stateUpdater: setAction }
    },
    q3() {
      return { nextState: 'q4', effect: yDelay }
    },
    q4() {
      // If another action has been received since the leading edge,
      // use that for the trailing edge.
      return channel.isEmpty()
        ? { nextState: 'q5', effect: yTake, stateUpdater: setAction }
        : { nextState: 'q5', effect: yNoop }
    },
    q5() {
      return { nextState: 'q2', effect: yFork(action) }
    },
  },
  needsChannel ? 'q1' : 'q2',
  `throttle(${safeName(patternOrChannel)}, ${worker.name})`,
)

...but channel.isEmpty() is a non-existent method. I'm not sure how to achieve this without some way of checking whether the channel is empty.

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.