Skip to content

Instantly share code, notes, and snippets.

View MHerszak's full-sized avatar

Michel Herszak MHerszak

  • Base2Industries
  • Berlin
View GitHub Profile
// Transduceres belong to the family of Structural design patterns compostion
// This GIST covers all of the cases that we would currently use
// .map, .filter, and .reduce for with arrays, and the
// composable transducers don’t make multiple copies of the data set.
// Transducers as developed for production code bases cover more use cases,
// such as replicating the functionality of .find.
// http://raganwald.com/2017/04/30/transducers.html
@MHerszak
MHerszak / CalculatorCommand.js
Last active November 20, 2018 20:52
Build a SOLID command pattern in Javascript
/**
* Command Interface
* @param {*} state
*/
const CommandI = (state) => ({
type: 'CommandI',
execute: (...rest) => state.execute(...rest),
});
/**
@MHerszak
MHerszak / CalculatorStrategy.js
Last active November 21, 2018 08:57
Build a SOLID strategy in Javascript
/**
* Command Interface
* @param {*} state
*/
const CommandI = (state) => ({
type: 'CommandI',
execute: (...rest) => state.execute(...rest),
});
/**
@MHerszak
MHerszak / Posts.js
Last active November 24, 2017 03:24
const options = {
name: 'posts.item',
// Which key should become data key for state in hoc
key: 'document',
// load initial data
async selectData(service, props) {
// if independent from another components props
return service.get(props.documentId)
import React, { Component } from 'react';
import errors from 'feathers-errors';
import { APP_REST } from './../../components/constants';
import { setDisplayName } from './utils';
import { forEach, omit } from './../../utils';
@MHerszak
MHerszak / withSubscription2.js
Last active November 2, 2017 23:09
withSubscription2.js
import React, { PureComponent } from 'react';
import errors from 'feathers-errors';
import { withPreloader } from './../../redux/container';
import { APP_REST } from './../../components/constants';
import { setDisplayName } from './utils';
componentDidMount() {
const events = [{
service: 'conversation',
event: 'created',
eventFunc: this.addConversation,
},
{
service: 'conversation',
event: 'removed',
eventFunc: this.removeConversation,
import React, { PureComponent } from 'react';
import { APP_REST } from './../../components/constants';
import { setDisplayName } from './utils';
import { forEach, map, arrayIsEmpty } from './../../utils';
class BaseType {
constructor(props) {