This file contains hidden or 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
function (root, args, context, info) { | |
return __awaiter(_this, void 0, void 0, function () { | |
var fragments, document, result; | |
return __generator(this, function (_a) { | |
switch (_a.label) { | |
case 0: | |
fragments = Object.keys(info.fragments).map(function (fragment) { return info.fragments[fragment]; }); | |
document = { | |
kind: graphql_1.Kind.DOCUMENT, | |
definitions: [info.operation].concat(fragments), |
This file contains hidden or 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
function delay(milliseconds: number, count: number): Promise<number> { | |
return new Promise<number>(resolve => { | |
setTimeout(() => { | |
resolve(count); | |
}, milliseconds); | |
}); | |
} | |
// async function always returns a Promise | |
async function dramaticWelcome(): Promise<void> { |
This file contains hidden or 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
+ // @flow | |
import React from "react"; | |
import gql from "graphql-tag"; | |
import { graphql } from "react-apollo"; | |
+ import type { OperationComponent } from "react-apollo"; | |
export const HERO_QUERY = gql` | |
query GetCharacter($episode: Episode!) { | |
hero(episode: $episode) { | |
name | |
id |
This file contains hidden or 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 { ChildProps } from "react-apollo"; | |
const withCharacter = graphql<Response, InputProps>(HERO_QUERY, { | |
options: ({ episode }) => ({ | |
variables: { episode } | |
}) | |
}); | |
class Character extends React.Component<ChildProps<InputProps, Response>, {}> { | |
render(){ |
This file contains hidden or 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
const Input = rc.compose( | |
- rc.withProps({component: "input", type: "text"}), | |
- rc.componentFromProp, | |
+ rc.componentFromProp, | |
+ rc.withProps({component: "input", type: "text"}), | |
)("component") |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Browse Ramda documentation in Terminal | |
# Requires jq and a tool such as fzf or peco for interactive filtering | |
LATEST="http://raine.github.io/ramda-json-docs/latest.json" | |
DOCS_URL="http://ramdajs.com/docs/" | |
json=$(curl -s $LATEST) | |
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end') |
This file contains hidden or 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
any | |
void | |
boolean | |
number | |
string | |
null | |
undefined |
This file contains hidden or 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
const initialState = { | |
user: { | |
name: 'anonymous', | |
token: null | |
} | |
} | |
const getUser = state => state.user || {} | |
const isAuthenticated = state => Boolean(getUser(state).token) | |
const isAnonymous = state => !isAuthenticated(user) |
This file contains hidden or 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 * as R from 'ramda' | |
const initialState = { | |
user: { | |
name: 'jack', | |
token: 111111 | |
}, | |
goods: { | |
slug: 1, |
This file contains hidden or 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
html{ | |
background:url("moon.jpg") no-repeat 100% 1em, | |
url("stars.jpg") repeat-x 0 0, | |
url("city.png") repeat-x bottom, | |
linear-gradient(black,#444); | |
background-color:#222; | |
min-height:100%; | |
} |