In your command-line run the following commands:
brew doctor
brew update
if (typeof window!=='undefined' && navigator.serviceWorker && navigator.serviceWorker.controller) { | |
let reloadOnNext = false; | |
let pushState = history.pushState; | |
history.pushState = function(state, title, url) { | |
pushState.call(this, state, title, url); | |
if (reloadOnNext===true) location.reload(true); | |
}; | |
navigator.serviceWorker.controller.addEventListener('statechange', e => { |
In your command-line run the following commands:
brew doctor
brew update
tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.
A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.
But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.
How do we solve this with React?
// using createRouteElement | |
import { Route, createRouteElement } from 'react-router' | |
const RouteWithQuery = (routeProps) => ( | |
<Route {...routeProps} render={props => ( | |
const query = parseQueryString(props.history.location.search) | |
return createRouteElement({ ...routeProps, ...props, query }) | |
)}/> | |
) |
// getComponent is a function that returns a promise for a component | |
// It will not be called until the first mount | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { |
import { createStore, combineReducers } from 'redux' | |
const createInjectableStore = (createStore) => { | |
return (reducers) => { | |
const store = createStore(combineReducers(reducers)) | |
const replace = () => { | |
store.replaceReducer(combineReducers(reducers)) | |
} | |
store.injectReducer = (key, reducer) => { | |
reducers[key] = reducer |
import fs from 'fs' | |
import { interpolateName } from 'loader-utils' | |
// webpack config | |
const publicPath = 'static' | |
const filenameTemplate = '[name].[hash].[ext]' | |
const extensions = [ | |
'png', 'jpg', 'jpeg', 'gif', | |
'ico', 'svg', 'otf', 'eot', 'svg', | |
'ttf', 'woff', 'woff2' |
package main | |
import ( | |
"golang.org/x/net/websocket" | |
"log" | |
"net/rpc/jsonrpc" | |
) | |
// In a real project, these would be defined in a common file | |
type Args struct { |
With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.
This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async
+ await
.
import React from 'react' | |
const provideContext = (contextKey, contextType) => ( | |
React.createClass({ | |
childContextTypes: { | |
[contextKey]: contextType | |
}, | |
getChildContext() { | |
const { children, ...props } = this.props |