Skip to content

Instantly share code, notes, and snippets.

View piq9117's full-sized avatar
💀
Nothing good is happening here

piq9117 piq9117

💀
Nothing good is happening here
View GitHub Profile
function fetchPosts (subreddit) {
return dispatch => {
dispatch(requestPosts(subreddit))
return fetch('http://www.reddit.com/r/${subreddit}.json')
.then(response => response.json())
.then(json => dispatch(receivePosts(subreddit, json)))
}
}
const MoverInputType = new GraphQLInputObjectType(MoverType);
const Mutation = new GraphQLObjectType({
name: 'Mutation',
description: 'methods to create mover',
fields: () => {
return {
addMover: {
type: MoverType,
args: {
'use strict';
const R = require('ramda');
const activityDetails = [
{
id: '395478',
title: 'Unique Warner Bros. Studio Tour London – The Making of Harry Potter',
imageUrl: '//a.travel-assets.com/lxweb/media-vault/395478_m.jpeg?v=102150',
largeImageURL: '//a.travel-assets.com/lxweb/media-vault/395478_l.jpeg?v=102150',
fromPrice: '$151',
function updateRecords (id, prop, value) {
if (prop === 'artist') {
collection[id][prop] = value
if (value === '') {
delete collection[id][prop]
}
}
else if (prop === 'tracks') {
const person = {
name: 'ken',
favoriteFood: []
}
function favoriteFood (food) {
person.favoriteFood.push(food)
}
favoriteFood('ramen')
// { name: 'ken', favoriteFood: [ 'ramen' ] }
/*
You can use any testing suite and assertion library you want.
I test with mocha & chai
*/
const person = {
name: 'ken',
favoriteFood: []
}
function favoriteFood (food) {
function reducer (state = person, action) {
switch (action.type) {
case 'ADD_FOOD':
return Object.assign({}, state, {
favoriteFood: state.favoriteFood.concat(action.data.food)
})
}
}
const person = {
name: 'ken',
favoriteFood: []
}
/*
It's the same reducer function from above, I just extracted the operation for
'ADD_FOOD', turned into a function and named it addFood.
*/
function addFood (state, action) {
const person = {
name: 'ken',
favoriteFood: []
}
function addFood (state, action) {
return Object.assign({}, state, {
favorite: state.favoriteFood.concat(action.data.food)
})
}