new Intl.NumberFormat([locales[, options]])
Intl.NumberFormat.call(this[, locales[, options]])
import time | |
class Bucket(object): | |
def __init__(self, max_amount, refill_time, refill_amount): | |
self.max_amount = max_amount | |
self.refill_time = refill_time | |
self.refill_amount = refill_amount | |
self.reset() | |
def _refill_count(self): |
const INCREMENT = 'INCREMENT', DECREMENT = 'DECREMENT'; | |
function reducer(state, action) { | |
switch (action.type) { | |
case INCREMENT: | |
return state + 1; | |
case DECREMENT: | |
return state - 1; | |
} | |
} |
var firstPaint = 0, firstPaintTime, paint; | |
function paintHandler() { | |
paint = window.performance.now() | |
if (firstPaint === 0) { | |
firstPaint = paint; | |
firstPaintTime = firstPaint + window.performance.timing.navigationStart; | |
window.performance.timing.firstPaint = firstPaint; | |
window.performance.timing.firstPaintTime = firstPaintTime; | |
} | |
}; |
// ------------ | |
// counterStore.js | |
// ------------ | |
import { | |
INCREMENT_COUNTER, | |
DECREMENT_COUNTER | |
} from '../constants/ActionTypes'; | |
const initialState = { counter: 0 }; |
// Simple wrapper to use bootstrap's grid system to position elements side-by-side | |
var VerticalFieldsElement = React.createClass({ | |
render: function() { | |
return dom.div( | |
{ className: 'clearfix' }, | |
React.Children.map(this.props.children, function(child) { | |
if(!child) { | |
return child; | |
} |
2015-01-29 Unofficial Relay FAQ
Compilation of questions and answers about Relay from React.js Conf.
Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.
Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).
"use strict"; | |
var _ = SM.import('lodash'); | |
var DOM = SM.import('sm-dom'); | |
var Uri = SM.import('sm-uri'); | |
// WebKit (as of version 538.35.8) fires a useless popstate event after every | |
// page load, even when the page wasn't popped off the HTML5 history stack. We | |
// only want to handle popstate events that result from a page actually being | |
// popped off the HTML5 history stack, so we need a way to differentiate between |
// default exports | |
export default 42; | |
export default {}; | |
export default []; | |
export default foo; | |
export default function () {} | |
export default class {} | |
export default function foo () {} | |
export default class foo {} |
This is a rough outline of some thoughts on how to leverage [SPDY Push][SPDY] externalize inline <script>
s that contain dynamic, page/user-specific configuration and state data to align with [CSP][].
We are building web apps where the initial rendering (HTML) is built server-side, and in order for the client-side JavaScript app to take over, the app's configuration and initial state are written to an inline <script>
element.