Skip to content

Instantly share code, notes, and snippets.

View goatslacker's full-sized avatar

Josh Perez goatslacker

View GitHub Profile
var alt = require('../alt')
var ChatThreadActionCreators = require('../actions/ChatThreadActionCreators')
var ChatServerActionCreators = require('../actions/ChatServerActionCreators')
var ChatMessageActionCreators = require('../actions/ChatMessageActionCreators')
var ThreadStore = require('../stores/ThreadStore')
var ChatMessageDataUtils = require('../utils/ChatMessageDataUtils')
var ChatMessageUtils = require('../utils/ChatMessageUtils')
function MessageStore() {
import { Actions } from 'flummox';
class MessageActions extends Actions {
createMessage(messageContent) {
return {
content: messageContent,
date: Date.now(),
};
}
}
<App>
<AltContainer store={CustomerStore}>
<Customer />
</AltContainer>
<section>
<h1>Selected Address</h1>
<div>
<div>
<AltContainer store={CustomerStore} inject={{
address: props => props.address
class XStore {
static displayName = 'XStore'
constructor() {
this.foo = 'bar'
this.exportPublicMethods({
getFoo: _ => this.foo
})
}
@goatslacker
goatslacker / alt-stateless.js
Last active August 29, 2015 14:20
A stateless store version of alt
import { Dispatcher } from 'flux'
function isPromise(obj) {
return obj && (typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function'
}
const inject = Math.random().toString(16).substr(2, 7)
class Alt {
@goatslacker
goatslacker / stateless-stores.js
Last active August 29, 2015 14:20
stateless stores with reduce
import { Dispatcher } from 'flux'
function isPromise(obj) {
return obj && (typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function'
}
// the minimalest
class Alt {
constructor() {
@goatslacker
goatslacker / transforms-with-alt.js
Last active August 29, 2015 14:20
Nuclear-style transforms for Alt stores
import Alt from './'
// the magic sauce
import { createTransform } from './utils/frp'
// decorator utilities
import { createStore, bind } from './utils/decorators'
const alt = new Alt()
@goatslacker
goatslacker / observe-actions.js
Created May 11, 2015 04:47
observe specific actions
import Alt from './'
import { ACTION_KEY } from './lib/symbols/symbols'
const alt = new Alt()
alt.observe = function (action) {
const chain = []
const subscriptions = []
this.dispatcher.register((payload) => {
@goatslacker
goatslacker / malt.js
Created May 13, 2015 05:46
Malt - A minimal alt
import { Dispatcher } from 'flux'
import transmitter from 'transmitter'
class Alt {
constructor() {
this.dispatcher = new Dispatcher()
}
createActions(model) {
import React from 'react'
import Alt from 'alt'
import connectToStores from 'alt/utils/connectToStores'
const alt = new Alt()
const TimelineStore = alt.createStore({
displayName: 'TimelineStore',
state: {}