Skip to content

Instantly share code, notes, and snippets.

@pablopaul
pablopaul / redux-store.js
Created November 21, 2016 12:26
Redux Store
import { createStore } from 'redux';
// reducer is the reducer we defined earlier
const store = createStore(reducer);
@pablopaul
pablopaul / redux-store-dispatch-action.js
Created November 21, 2016 12:31
Redux Store Dispatch Action
store.dispatch(
{
type: 'CHARACTER_TYPED',
char: 'x'
}
);
@pablopaul
pablopaul / redux-store-getstate.js
Created November 21, 2016 12:34
Redux Store getState
const state = store.getState();
// Logs 'x'
console.log(state);
@pablopaul
pablopaul / redux-store-subscribe.js
Created November 21, 2016 12:39
Redux Store Subscribe
const unsubscribe = store.subscribe( () => console.log( store.getState() ) );
@pablopaul
pablopaul / redux-store-subscriber-demo.js
Created November 21, 2016 12:44
Redux Store Subscriber Demo
// 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());
@pablopaul
pablopaul / redux-store-unsubscribe.js
Created November 21, 2016 12:47
Redux Store Unsubscribe
unsubscribe();
// Nothing is logged
store.dispatch(insertCharacter('z'));
sudo npm install -g sloc
sloc src/
@pablopaul
pablopaul / deploy.rb
Last active February 5, 2019 19:19 — forked from cannikin/deploy.rb
Notify Sentry of a new release via Capistrano with Auth Token
# 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 April 18, 2018 23:34 — forked from peduarte/testing-react-components.txt
Fix "ReferenceError: document is not defined" in jsdom + enzyme + ava environment.
/*
* Step 1
*/
npm install --save-dev jsdom
/*
* Step 2 (http://airbnb.io/enzyme/docs/guides/jsdom.html)
*
* test-browser-env.js