the following is the code used for this lighting talk https://slides.com/allthedey/async-vs-promise
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 { createMessage as createMessageBase, requestMessage, addToCollection } from '../../../store/modules/message'; | |
import { tryCatchAxiosAction } from '../../../services/api-client'; | |
/* :: | |
type Message = { | |
message_id: string | |
} | |
*/ |
- node 8 -> it's cool to install w/ nvm
then nvm install v8 --lts
- kubernetes & minikube
- git-crypt (eventually via your distribution package manager)
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 React, { Component } from 'react' | |
import PropTypes from 'prop-types' | |
// ... | |
class Foo extends Component { | |
createHandleSearchChange = (tags) => terms => | |
this.setState({ foundTags: whateverFindAlgo(tags, terms)}) | |
handleAddTag = (updateEntityTags, entity, tag) => { | |
updateEntityTags(entity, [...entity.tags, tag]) |
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 { createSelector } from 'reselect'; | |
import { connect } from 'react-redux'; | |
import { currentTabSelector } from '../store/selectors/tab'; | |
const mapStateToProps = createSelector( | |
[currentTabSelector], | |
currentTab => ({ | |
currentTab, | |
}) | |
); |
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
favoriteAddressFilter = (addresses, searchTerms) => addresses.reduce((acc, address) => { | |
if (!acc) { | |
return address; | |
} | |
if (address.startsWith(searchTerms) && !acc.startsWith(searchTerms)) { | |
return address; | |
} | |
if (!acc.is_primary && address.is_primary === true) { |
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
#!/bin/bash | |
set +e | |
set -v | |
docker-compose stop | |
docker-compose rm | |
docker volume rm devtools_db devtools_index devtools_store | |
docker-compose up -d redis cassandra elasticsearch | |
sleep 20 |
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
// unit test of redux middleware w/ jest | |
import configureStore from './configure-store'; | |
const middleware = store => next => (action) => { | |
if (action.type === 'FOO') { | |
Promise.resolve({ type: 'FOO_SUCCESS', payload: {} }).then(act => store.dispatch(act); | |
} | |
return next(action); |
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
package http_middleware | |
import ( | |
"encoding/base64" | |
"encoding/json" | |
"gopkg.in/gin-gonic/gin.v1" | |
"gopkg.in/redis.v5" | |
"net/http" | |
"strconv" | |
"strings" |
NewerOlder