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

Debounce issue with multiple logics of the same action type #132

Open
kevinnguy opened this issue Nov 6, 2018 · 0 comments
Open

Debounce issue with multiple logics of the same action type #132

kevinnguy opened this issue Nov 6, 2018 · 0 comments

Comments

@kevinnguy
Copy link

In this following code:

const ACTION_TYPE_A = 'action_type_a';

const firstLogic = createLogic({
  type: ACTION_TYPE_A,
  
  process: ({ action }) => {
    console.log("first logic");
    // return something
  }
});

const secondLogicWithDebounce = createLogic({
  type: ACTION_TYPE_A,
  debounce: 2000,
  
  process: ({ action }) => {
    console.log("second logic with debounce");
    // return something
  }
});

...

componentDidMount() {
  console.log("dispatching action_type_a");
  dispatch({ type: ACTION_TYPE_A });
}

I expect the console log output to be:

dispatching action_type_a
first logic

// wait for 2 seconds from debounce: 2000

second logic with debounce

but I'm getting:

dispatching action_type_a

// wait for 2 seconds from debounce: 2000

first logic
second logic with debounce

I expect firstLogic to be processed immediately when dispatching its action type but it seems like the debounce param from secondLogicWithDebounce is applying its operators onto other logics that share the same action type. Is this behavior normal?

Thanks for the awesome library @jeffbski !!

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

1 participant