Skip to content

Instantly share code, notes, and snippets.

View AvraamMavridis's full-sized avatar
🎯
Focusing

Avraam Mavridis AvraamMavridis

🎯
Focusing
View GitHub Profile
@v0lkan
v0lkan / invalidate.js
Created March 13, 2017 16:38
Invalidates ServiceWorkers so that you can fetch your assets freshly.
/**
* Invalidates the current `ServiceWorker` running on the page.
* Why? Because managing a cache is damn hard; and sometimes due to race conditions
* your assets might get out-of-sync.
*
* This mini snippet checks the version of the app against an uncached resource and
* invalidates the workers if it finds a mismatch.
*/
if ( navigator.serviceWorker && navigator.serviceWorker.getRegistrations ) {
@mehiel
mehiel / FluxComponent.js
Last active August 29, 2018 17:45
Thinking on a FluxComponent
import { Component } from 'react'
import propOr from 'ramda/src/propOr'
import identity from 'ramda/src/identity'
import map from 'ramda/src/map'
import compose from 'ramda/src/compose'
class FluxComponent extends Component {
static createReducer = (initialState, handlers) => (state = {}, action) =>
propOr(identity, action.type, handlers)(state, action)
@bvaughn
bvaughn / index.md
Last active February 25, 2025 15:56
Interaction tracing with React

This API was removed in React 17


Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

@th3hunt
th3hunt / pan.js
Last active August 19, 2020 08:14
Pan gesture helpers
/**
* Pan
* ---
*
* A collection one-finger Pan gesture recognizers.
*
* A pan is an omnidirectional one- or two-finger gesture that expands the field of view.
* Drag is typically used with pan.
*
*/