Skip to content

Instantly share code, notes, and snippets.

View btg5679's full-sized avatar
🎯
Focusing

bg btg5679

🎯
Focusing
View GitHub Profile
const store = createStore(r, {
user: {
name: 'wacko',
age: 48
},
comments: ['hi', 'hola']
});
const store = createStore(r, {
user: {
name: 'wacko',
age: 48
},
comments: ['hi', 'hola']
});
@btg5679
btg5679 / ReduxExampleStore
Last active July 14, 2017 01:59
Redux Example Store
import { createStore } from 'redux';
const store = createStore(r, {
user: {
name: 'wacko',
age: 48
},
commentCount: 2,
loginHistory: {
loginDate: '2017-01-01',
import { createStore } from 'redux';
const store = createStore(r, {
user: {
name: 'wacko',
age: 48
},
commentCount: 2,
loginHistory: {
loginDate: '2017-01-01',
import { createStore } from 'redux';
const reducer = function(state, action){
if(action.type === 'CMT'){
return state + action.payload;
}
return state;
}
const store = createStore(r, {
@btg5679
btg5679 / ReduxIntro1.txt
Last active July 14, 2017 20:00
ReduxIntro1
import { createStore } from 'redux';
// Store
const dataStore = createStore(r, {
beerlist: {
name: 'IPA',
abv: 7.4
},
beersOnTap: 1,
liveMusicHistory: {
@btg5679
btg5679 / ReduxIntro2
Last active July 14, 2017 20:00
ReduxIntro2
import { createStore } from 'redux';
// Store
const dataStore = createStore(r, {
beerlist: {
name: 'IPA',
abv: 7.4
},
beersOnTap: 1,
liveMusicHistory: {
import { createStore } from 'redux';
// Store
const dataStore = createStore(r, {
beerlist: {
name: 'IPA',
abv: 7.4
},
beersOnTap: 1,
liveMusicHistory: {
import { createStore } from 'redux';
// Store
const dataStore = createStore(r, {
beerlist: {
name: 'IPA',
abv: 7.4
},
beersOnTap: 1,
liveMusicHistory: {
var a = { name: 'Pilsner', abv: 5.4 };// Remains untouched
var b = Object.assign({}, a, {abv: 6.7})// b = { name: 'Pilsner', abv: 6.7 }}
var a = [0, 1, 2]// Remains untouched
var b = a.concat(3)// b = [0, 1, 2, 3]
var c = a.filter((val) => != 2)// c = [0, 1, 3]
var a = {name: 'Dave Matthews', songs: [0, 1, 2]}// Remains untouched
var b = Object.assign({}, a, {name: 'Jack Johnson'});// b = {name: 'Jack Johnson', songs: [0, 1, 2]}
b.songs = a.songs.concat(3);// b = {name: 'Jack Johnson', things: [0, 1, 2, 3]}