Skip to content

Instantly share code, notes, and snippets.

View Bitaru's full-sized avatar
:octocat:

Vitaly Danilov Bitaru

:octocat:
View GitHub Profile
@Bitaru
Bitaru / actions.js
Created October 11, 2017 11:09
redux-shelf
import { createAction } from 'redux-actions';
import { identity, isArray } from 'lodash';
import { SubmissionError } from 'redux-form';
export const PREFIX = '@@shelf';
export const statuses = ['START', 'SUCCESS', 'ERROR'];
const getType = (status:string) => (name):string => `${PREFIX}/${status} -> ${name.toString()}`
const createApiAction = (name, status) => createAction(
@Bitaru
Bitaru / index.js
Created August 25, 2017 07:06
Proxy product click
window.findifyApiRegistry = [{
hook: "*.item",
mapProps: function(props) {
return {
onClick: function(e) {
e.preventDefault();
return props.onProductClick({
id: props.id,
product_url: props.product_url // You can modify url
})
window.findifyApiRegistry = [{
hook: '*facets',
didMount: function(res){
var node = res.node;
var props = res.data;
var min = res.data.from;
var max = res.data.to;
var onChange = res.data.onChange;
var slider = document.createElement('div');
@Bitaru
Bitaru / default.js
Created January 25, 2017 13:36
webpack 2.2.0 config
const path = require('path');
module.exports.createRules = (rules, initial = {}) =>
Object.keys(rules).reduce((acc, selector) =>
(acc[selector] = Object.assign(
{},
acc[selector],
rules[selector],
{ test: new RegExp(`/\.${selector}$\/`) })
) && acc
- block spread(fn)
: args = [].slice.call(arguments, 1)
{fn}.apply(this, [].slice.call(arguments).concat({args|json}))
import { combineReducers } from "redux";
import { routerReducer } from "react-router-redux";
import { reducer as formReducer } from "redux-form";
import { Record, Map } from 'immutable';
const reducersCache = {};
class Test extends Record ({
item: 1
}){
import { Route } from 'react-router';
import isUndefined from 'lodash/isundefined';
import every from 'lodash/every';
import some from 'lodash/some';
const hasFeatures = (features, exposes) =>
isUndefined(exposes) || every(exposes, feature => features.includes(feature));
const hasAccess = ({ accesses }, mandatory, optional) =>
@Bitaru
Bitaru / DBService.js
Last active July 29, 2016 11:31
Simplest way to connect CRUD data to layout
import { createReducer } from 'redux-act';
import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';
import isEmpty from 'lodash/isEmpty';
import withMessage from './withMessage';
import { connect } from 'react-redux';
import compose from 'recompose/compose';
import createEagerFactory from 'recompose/createEagerFactory';
import { asyncConnect } from 'redux-async-connect';
import { createSelector, createStructuredSelector } from 'reselect';
@Bitaru
Bitaru / handleReduxForm.js
Last active July 2, 2016 13:55
Handle redux form submiting with async actions
import { batchActions } from 'redux-batched-actions';
/**
* Create a function which will handle error in request
* and dispatch rest actions on success.
* You can also use .then(data => ...) to do something on sucess
*
* @param Promised action
* @param ... other actions
{
name: 'demo_front',
target: 'web',
node: {
fs: 'empty'
},
output: {
publicPath: '/',
filename: '[name].js',
chunkFilename: 'chunk.[name].js',