Currently it for clent-side apps only. Not for universall (isomorphic) apps. Will add it soon
I'm using the promise middleware to dispatch actions like this:
import express from 'express'; | |
import cors from 'cors'; | |
import graphQLHTTP from 'express-graphql'; | |
import path from 'path'; | |
import webpack from 'webpack'; | |
import WebpackDevServer from 'webpack-dev-server'; | |
import {Schema} from './data/schema'; | |
const APP_PORT = 3000; | |
const GRAPHQL_PORT = 8080; |
Currently it for clent-side apps only. Not for universall (isomorphic) apps. Will add it soon
I'm using the promise middleware to dispatch actions like this:
/* | |
Basically "web3" comes from Mist, | |
but "Web3" CAN come from the dapp. | |
A Dapp has 3 ways to use web3. | |
2. and 3. would work when in Mist and outside. | |
*/ | |
// 1. simply use, web3 comes already defined |
gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'
Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component
(and thus, prerendering).
Note that jquery-rails
can be removed from Gemfile, the npm version of jquery
and jquery-ujs
will be used instead.
// App Components | |
class App extends React.Component { | |
constructor(){ | |
super(); | |
this.state = {activeRoom: "general", messages: [], channel: socket.channel("rooms:general")}; | |
} | |
componentDidMount() { | |
this.configureChannel(this.state.channel); |
/* | |
* Utility to only call Redux updates in RequestAnimationFrame's | |
* Also uses React-dom's batchedUpdates | |
*/ | |
import raf from 'raf'; | |
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom'; | |
let rafID; | |
let notifyFunc; | |
function animFrame() { |
contract random{ | |
function rand(uint min, uint max) public returns (bytes32){ | |
uint256 lastBlockNumber = block.number - 1; | |
bytes32 hashVal = bytes32(block.blockhash(lastBlockNumber)); | |
return bytes32(hashVal); | |
} | |
} |
contract random { | |
/* Generates a random number from 0 to 100 based on the last block hash */ | |
function randomGen(uint seed) constant returns (uint randomNumber) { | |
return(uint(sha3(block.blockhash(block.number-1), seed ))%100); | |
} | |
/* generates a number from 0 to 2^n based on the last n blocks */ | |
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) { | |
uint n = 0; | |
for (uint i = 0; i < size; i++){ |
import { combineEntitiesReducers } from 'redux-entities'; | |
import messages from './messages'; | |
import tickets from './tickets'; | |
export default combineEntitiesReducers({ | |
messages, | |
tickets | |
}); |
if (action.toindex < 0) return state; | |
var olditem = state.get(action.index); | |
var newlist = state.delete(action.index).insert(action.toindex, olditem); | |
return newlist; |