Skip to content

Instantly share code, notes, and snippets.

@chris-pardy
chris-pardy / catch-function.js
Created April 10, 2019 04:40
Catchable Functions
Function.prototype.catch = function(callback) {
const f = this;
return function(...args) {
try {
const v = f.apply(this, args);
if ('then' in v && 'catch' in v) {
return v.catch(callback);
}
return v;
} catch (err) {
import {stacks} from '@rategravity/service-lib';
import create from '../lambda/create';
import update from '../lambda/update';
import get from '../lambda/get';
export default stacks.api()
.get('/resource/:id', get) //the functions are "semi-enhanced lambdas"
.put('/resource/:id', create)
.post('/resource/:id', update);
@chris-pardy
chris-pardy / index.tsx
Last active February 14, 2019 05:12
react-redux hooks
import React from 'react';
import {
Store,
Action,
Dispatch,
AnyAction,
ActionCreator,
ActionCreatorsMapObject,
bindActionCreators
} from 'redux';

Keybase proof

I hereby claim:

  • I am chris-pardy on github.
  • I am chrispardy (https://keybase.io/chrispardy) on keybase.
  • I have a public key whose fingerprint is EFDD 926B 5319 20E0 F8E6 BD8B 3342 34F9 004E 3CCE

To claim this, I am signing this object: