question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redux-debounced support

See original GitHub issue

https://www.npmjs.com/package/redux-debounced

I’m trying to use redux-debounced which doesn’t work due to how polymer-redux proxies the calls to dispatch. Redux debounced is looking for a meta key off of the function, this doesn’t work due to https://github.com/tur-nr/polymer-redux/blob/master/src/index.js#L180-L190. Which copies the function removing the meta object that I add.

export function trackCustomerSearch(key) { const thunk = dispatch => { console.log('Search Key ----> ', key); }; thunk.meta = { debounce: { time: 2500, key: 'TRACK_CUSTOMER_SEARCH' } }; return thunk; }

My additional question is why is polymer-redux doing that? Is redux-thunk not needed due to those lines? I’d prefer to just use redux-thunk so other redux middlewares will work as expected.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chiefcllcommented, Sep 3, 2017

👍

Plan moving forward is good. With the 2.0 version I’d recommend you emphasize the decoupling of redux from Polymer Redux. Having your action creators in Polymer components creates a tight coupling. We like to have the redux layer be reusable with any frontend framework. We do that like this:

import actions from '../redux/actionCreators.js';
let PolymerReduxMixin = PolymerRedux(store);
const ReduxMixin = function(Base) {
    return class ReduxActions extends PolymerReduxMixin(Base) {
      static get actions() {
        return actions;
      }

      get actions() {
        return actions;
      }
    };
  };

This exposes all the actionCreators to polymer components so they can do this.dispatch(this.actions.bar()).

0reactions
chiefcllcommented, Sep 4, 2017

And it may even be better to do

import actions from '../redux/actionCreators.js';
let PolymerReduxMixin = PolymerRedux(store, actions);

Where actions is an object of {'MY_ACTION_CREATOR': function()}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debounce Your React and Redux Code to Improve Performance
A debounce is a tool that every web developer should have in their kit. It improves performance by limiting the number of expensive...
Read more >
redux-debounced - npm
Debounce allows you to discard a fast paced action from updating your state until a certain period of time passes after the last...
Read more >
Debouncing with Redux Middleware | TypeOfNaN
Let's implement debouncing functionality using Redux middleware!
Read more >
Debounce API call in redux - reactjs - Stack Overflow
I am trying to use the redux-debounced middleware. But I noticed it only helps in delaying the updating of the state.
Read more >
Debouncing React's Controlled Textareas w/ Redux & Lodash
The way that I've figured out to do it is to make sure that the <textarea> is injected from another component, say <MyTextarea>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found