This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In JSX, callback can get passed directly as part of api | |
<MyComponent onSomething={handler} /> | |
// With events, there is a disconnect between the event publisher and the consumer of the event | |
<my-component></my-component> | |
// Some parent, but could be multiple, hard to follow | |
let myComponent = this.querySelector('my-component'); | |
myComponent.addEventListener('something', handler); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const moment = require('moment'); | |
const json = require('./greg-babiarss-blog.ghost.2017-05-13.json'); | |
json.data.posts | |
.filter(p => p.status === 'published') | |
.forEach(({title, slug, published_at: published, markdown}) => { | |
const date = moment(published).format('YYYY-MM-DD'); | |
const content = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createStore = (reducer, initialState) => { | |
let dispatcher$ = new Rx.Subject(); | |
let state$ = new Rx.BehaviorSubject(initialState); | |
dispatcher$.scan(reducer, state$.getValue()).subscribe(state$); | |
return { | |
dispatch(action) { | |
dispatcher$.next(action); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import axios from 'axios'; | |
import Rx from 'rxjs'; | |
export default class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
scores: [] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Serializer = DS.RESTSerializer.extend({ | |
keyForAttributeName: function(type, name) { | |
return name; | |
}, | |
keyForBelongsTo: function(type, name) { | |
var key = this.keyForAttributeName(type, name); | |
if (this.embeddedType(type, name)) { | |
return key; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest; | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
watch: { | |
all: { | |
files: ['Gruntfile.js'] | |
} | |
}, | |
connect: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('calling myFunc twice with the same url should only make one request to that url', function() { | |
var fakeServer = sinon.fakeServer.create(), // initialize fake server | |
myModule = myModule(), // whatever you need to do to instantiate your system under test | |
url = '/user/12', | |
callback = function() {}; // does nothing | |
fakeServer.autoRespond = true; // make sure the fake response is sent after every request | |
fakeServer.respondWith('GET', url, | |
[200, { 'Content-Type': 'application/json' }, '[{ "id": 12, "name": "John Doe" }]']); // define your fake response that the url will send | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mixin1, mixin2, mixinArray; | |
mixin1 = { | |
something: function() { | |
return 'something'; | |
} | |
}; | |
mixin2 = { | |
another: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.board { width: 500px; height: 500px; background-color: #ff6a00 } | |
} |