This document details some tips and tricks for creating redux containers. Specifically, this document is looking at the mapDispatchToProps
argument of the connect
function from [react-redux][react-redux]. There are many ways to write the same thing in redux. This gist covers the various forms that mapDispatchToProps
can take.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Types | |
class BaseConnection < BaseObject | |
# For some reason these are needed, they call through to the underlying connection wrapper. | |
extend Forwardable | |
def_delegators :@object, :cursor_from_node, :parent | |
# When this class is extended, add the default connection behaviors. | |
# This adds a new `graphql_name` and description, and searches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "react"; | |
import { print } from "graphql-tag/printer"; | |
import { graphql } from "react-apollo"; | |
import { MockedProvider } from "react-apollo/test-utils"; | |
import { addTypenameToDocument } from "apollo-client/queries/queryTransform"; | |
import { mount } from "enzyme"; | |
import { withSavedPayments, SAVED_ACCTS_QUERY } from "../"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CamelCaseMiddleware | |
def call(parent_type, parent_object, field_definition, field_args, query_context, next_middleware) | |
next_middleware.call([parent_type, parent_object, field_definition, transform_arguments(field_args), query_context]) | |
end | |
def transform_arguments(field_args) | |
transformed_args = {} | |
types = {} | |
field_args.each_value do |arg_value| |
First, we need to define interfaces with which we will work:
export interface Interceptable<T extends Interceptor<any, any>> {
addInterceptor(interceptor: T): Interceptable<T>;
removeInterceptor(interceptor: T): Interceptable<T>;
clearInterceptors(interceptors?: T[]): Interceptable<T>;
}
export interface Interceptor<T, D> {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paths and constants | |
var path = require('path') | |
var SRC_PATH = path.resolve('./src') | |
var DIST_PATH = path.resolve('./build') | |
var OUTPUT_FILENAME = '[name].[chunkhash].js' | |
var DEV_REGEXP = (/(^babel-?.*|.*-plugin$|.*-loader)/) | |
var DOT_ENV_SAMPLE_PATH = path.resolve('./.env.default') | |
var DOT_ENV_PATH = path.resolve('./.env') | |
var pkg = require('./package.json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Material UI multi select | |
* | |
* Use with: | |
* <MultiSelect fullWidth={true} value={this.state.values} onChange={(e,v) => this.setState({values: v})}> | |
* <ListItem primaryText={"Option 1"} value={1} /> | |
* <ListItem primaryText={"Option 2"} value={2} /> | |
* <ListItem primaryText={"Option 3"} value={3} /> | |
* <ListItem primaryText={"Option 4"} value={4} /> | |
* </MultiSelect> |
A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
NewerOlder