Skip to content

Instantly share code, notes, and snippets.

View goatslacker's full-sized avatar

Josh Perez goatslacker

View GitHub Profile
export const displayName = 'reducer store';
export const state = { count: 0 };
export const reduce = (state, payload) => {
if (payload.action === 'increment') {
return { count: state.count + 1 };
} else {
return state;
}
import Alt from 'alt'
import assign from 'object-assign'
const alt = new Alt()
class BaseStore {
constructor() {
this.state = {
a: 1
}
import Alt from './'
const alt = new Alt()
const foo = alt.createActions({
one() {
setTimeout(() => {
foo.two()
})
// include this file at the very beginning
import makeFinalStore from 'alt/utils/makeFinalStore'
// you'll also need to import your alt instance from wherever...
import alt from './somewhere/in/your/file/system/alt'
// this loads the app state from local storage and bootstraps it
const state = LocalStorage.getItem('my_app_state')
alt.bootstrap(state)
'use strict'
const callThing = require('./transpiled-babel-code.js')
class OtherClass { }
callThing(OtherClass, 1, 2, 3)
import Alt from 'alt'
import axios from 'axios'
const alt = new Alt()
const actions = alt.generateActions('ok', 'fail')
const Source = {
a: {
remote() {
import Alt from 'alt'
const alt = new Alt()
function callback(f) {
setTimeout(f)
}
class Actions {
a() {
function broken(x, ...foo) {
if (true) {
// this line creates an IIFE
class Foo extends Bar {
// constructors with rest throw things off
constructor(...other) {
super(...other)
}
}
import React from 'react'
export function withData(fetch, MaybeComponent) {
function bind(Component) {
return React.createClass({
contextTypes: {
universalId: React.PropTypes.string.isRequired,
buffer: React.PropTypes.object.isRequired
},
class Bar { }
function hello(one, two, three) {
console.log(1, one, 2, two, 3, three)
return one + two + three
}
function broken(x, ...foo) {
if (true) {
// this line creates an IIFE