JSFiddle - React, Tailwind, and code Playground

by mcsf

HTML

<script src="https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js"></script>

CSS

body { font-family: monospace; }

Babel + JSX

const w = s => document.body.innerText += s;
const l = s => w( `> ${s} \n` );

const common = {
	locales: user => l( `Calypso loading locales for ${user}` ),
};

const project = {
	name: 'Foo',
	locales: user => l( `${project.name} loading locales` ),
};

const invokeInCommon = _.partial( _.invoke, common );
const invokeInProject = _.partial( _.invoke, project );
const invoke = _.over( [ invokeInCommon, invokeInProject ] );
invoke( 'locales', 'hello' );

// same thing
w( '\nShorter implementation:\n\n' );
const invoker = ( ctx ) => ( ...args ) => _.invoke( ctx, ...args );
const invoke2 = _.over( [ common, project ].map( invoker ) );
invoke2( 'locales', 'hellooo' );