Skip to content

Instantly share code, notes, and snippets.

View swazza's full-sized avatar

Swarup Karavadi swazza

  • Hyderabad, India
View GitHub Profile
@swazza
swazza / .js
Created May 10, 2017 10:53
Pipeline Processor Using Reduce
function add(i) {
return i + 1;
}
function mul(i) {
return i * 2;
}
function sqr(i) {
return i * i;
@swazza
swazza / .js
Created May 9, 2017 13:31
Redux colocate component & data
// Component5.js
const _Component5 = ({ props: {foo5, bar5}}) => (
<div>
<span>{foo5}</span>
<span>{bar5}</span>
</div>
)
const mapStateToProps = (state) => ({ foo5: state.foo5, bar5: state.bar5 })
export const Component5 = connect(mapStateToProps, null)(_Component5)
@swazza
swazza / .js
Last active May 9, 2017 13:21
Redux Container vs Presentational
// Component5.js
const Component5 = ({ props: {foo5, bar5}}) => (
<div>
<span>{foo5}</span>
<span>{bar5}</span>
</div>
)
// Component4.js
const Component4 = ({ props: {foo4, bar4}}) => (
@swazza
swazza / .js
Created May 9, 2017 12:22
Ridiculously Simple SAGA Coordinator
function bookCar() {
console.log('%c Starting Book Car Task', 'color: blue');
console.log('...');
console.log('...');
console.log('%c Car Booking Confirmed.', 'color: green');
console.log('%c Book Car Task done.', 'color: blue');
return true;
}
function bookHotel() {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="mount">
<button id="decrement">-</button>
@swazza
swazza / declarativeValidator.js
Last active August 29, 2015 14:00
cookbook: jQuery global validator
var declarativeValidator = function () {
var dictionary = {}; // dictionary of form names and their submitHandlers
var init = function () {
initForms();
}
var initForms = function () {