Skip to content

Instantly share code, notes, and snippets.

Michel Herszak MHerszak

  • Base2Industries
  • Berlin
View GitHub Profile
View Transducer.js
// 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 Nov 20, 2018
Build a SOLID command pattern in Javascript
View CalculatorCommand.js
/**
* Command Interface
* @param {*} state
*/
const CommandI = (state) => ({
type: 'CommandI',
execute: (...rest) => state.execute(...rest),
});
/**
@MHerszak
MHerszak / CalculatorStrategy.js
Last active Nov 21, 2018
Build a SOLID strategy in Javascript
View CalculatorStrategy.js
/**
* Command Interface
* @param {*} state
*/
const CommandI = (state) => ({
type: 'CommandI',
execute: (...rest) => state.execute(...rest),
});
/**
View Posts.js
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)
View withEvents.js
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 Nov 2, 2017
withSubscription2.js
View 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';
View badExample.js
componentDidMount() {
const events = [{
service: 'conversation',
event: 'created',
eventFunc: this.addConversation,
},
{
service: 'conversation',
event: 'removed',
eventFunc: this.removeConversation,
View withSubscription.js
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) {
You can’t perform that action at this time.