Skip to content

Instantly share code, notes, and snippets.

View redux-store.js
import { createStore } from 'redux';
// reducer is the reducer we defined earlier
const store = createStore(reducer);
View redux-store-dispatch-action.js
store.dispatch(
{
type: 'CHARACTER_TYPED',
char: 'x'
}
);
View redux-store-getstate.js
const state = store.getState();
// Logs 'x'
console.log(state);
View redux-store-subscribe.js
const unsubscribe = store.subscribe( () => console.log( store.getState() ) );
View redux-store-subscriber-demo.js
// Logs 'x'
store.dispatch(insertCharacter('x'));
// Logs 'xy'
store.dispatch(insertCharacter('y'));
// `removeCharacter` is an action creator wrapping the `BACKSPACE` action
// Logs 'x'
store.dispatch(removeCharacter());
// Logs ''
store.dispatch(removeCharacter());
View redux-store-unsubscribe.js
unsubscribe();
// Nothing is logged
store.dispatch(insertCharacter('z'));
@pablopaul
pablopaul / deploy.rb
Last active Feb 5, 2019 — forked from cannikin/deploy.rb
Notify Sentry of a new release via Capistrano with Auth Token
View deploy.rb
# This task will notify Sentry via their API[1] that you have deployed
# a new release. It uses the release timestamp as the `version`
# (like 20151113182847) and the git ref as the optional `ref` value.
#
# This task requires several environment variables be set (or just
# hardcode the values in here if you like living on the edge):
#
# ENV['SENTRY_API_ENDPOINT'] : API endpoint, https://app.getsentry.com
# ENV['SENTRY_ORG'] : the organization for this app
# ENV['SENTRY_PROJECT'] : the project for this app
@pablopaul
pablopaul / testing-react-components.js
Last active Apr 18, 2018 — forked from peduarte/testing-react-components.txt
Fix "ReferenceError: document is not defined" in jsdom + enzyme + ava environment.
View testing-react-components.js
/*
* Step 1
*/
npm install --save-dev jsdom
/*
* Step 2 (http://airbnb.io/enzyme/docs/guides/jsdom.html)
*
* test-browser-env.js