Open in app
Cing Sian Dal
41 Followers
About

Sign in

41 Followers
About
Open in app

How dispatch works in Reducer pattern

Cing Sian Dal

Cing Sian Dal

Jun 11, 2020·1 min read

Well, it uses two parentheses of functions, one anonymous function.

// addBlogPost
function foo(bar) {
return (a, b) => {
bar(a, b);
}
}
// dispatch
function bar(a, b) {
console.log(a, b);
}
foo(bar)(1, 2);

Written by

Cing Sian Dal

Don’t follow me. I wrote junks here. Follow me on Twitter instead.

  • Usereducer
  • React Native
  • Context

More from Cing Sian Dal

Don’t follow me. I wrote junks here. Follow me on Twitter instead.

More From Medium

14 Essential Tools To Complete Your React Developer Toolbox

Amy J. Andrews in JavaScript In Plain English

Dev.Series — How to develop your first Angular 5 ÐApp on evan.network!

Sebastian Dechant in evan.network

The Best JavaScript Starter Kits for Your Next Project

Indrek Lasn in Better Programming

Delivering JSON Data with Netlify

Alex Merced Coder

How To Create a Swipeable Button in JavaScript (React)

Rinas Musthafa in Better Programming

Useful hidden features in JavaScript Console

Denis Cangemi in JavaScript In Plain English

Using Arrow Functions in JavaScript

John Au-Yeung in The Startup

Building a React component library with styled-components: Input Field

Fionna Chan

About

Help

Legal

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store