Skip to content

Instantly share code, notes, and snippets.

View goatslacker's full-sized avatar

Josh Perez goatslacker

View GitHub Profile
var React = require('react')
var foo = React.createClass({
render: function () {
return React.createElement('select', null, [
React.createElement('option', {
key: 1,
value: 1,
dangerouslySetInnerHTML: { __html: '<strong>yes</strong>' },
}),
@goatslacker
goatslacker / original.js
Created November 11, 2015 01:59
Babel 6 bug with default arguments in classes
class Z {
x(y = 2) {
return y
}
}
@goatslacker
goatslacker / dataSources.js
Last active November 5, 2015 20:52
dataSources.js
import isPromise from 'is-promise'
import { generateActions } from 'create-actions'
// get the action creators that will be created given a namespace
export const getActionCreators = (namespace) => {
return generateActions(namespace, [
'begin',
'success',
'failure',
'end',
import AltContainer from 'alt/AltContainer'
import React from 'react'
class Child extends React.Component {
foo() {
console.log('im here')
}
render() {
return <div onClick={this.foo}>click me</div>
@goatslacker
goatslacker / fluxForm.js
Created October 1, 2015 00:07
handle forms using any flavor of flux
const fsa = (type, payload) => {
return {
// FSA
type,
payload,
// Alt
action: type,
data: payload,
}
}
import Alt from 'alt'
const alt = new Alt()
const actions = alt.generateActions('test')
const store1 = alt.createStore({
displayName: 'store1',
bindListeners: {
@goatslacker
goatslacker / components_InfoView.jsx
Last active October 1, 2015 00:05
The new alt connect?
class InfoView extends React.Component {
render() {
return <div>{this.props.things}</div>
}
}
export default connect({
listenTo() {
return [InfoStore]
},
export default function fetch(store, source) {
const storeInst = store.getInstance ? store.getInstance() : store
const state = storeInst.getState()
const validHandlers = ['success', 'failure', 'begin', 'end']
validHandlers.forEach((handler) => {
if (source[handler] && !source[handler].id) {
throw new Error(`${handler} handler must be an action function`)
}
})
@goatslacker
goatslacker / bad.js
Created August 20, 2015 00:19
Actions that depend on other actions
class TodoStore {
createdTodo(todo) {
this.todos.push(todo)
}
save() {
...
}
}