These examples for:
- [email protected]
[email protected]
and above
flow-typed install # for initial run
import * as A from 'fp-ts/Array'; | |
import { pipe } from 'fp-ts/function'; | |
import * as IO from 'fp-ts/IO'; | |
// Space: https://unicodeplus.com/U+0020 | |
const space = String.fromCharCode(32); | |
// Narrow No-Break Space: https://unicodeplus.com/U+202F | |
const narrowNoBreakSpace = String.fromCharCode(8239); | |
// Thin Space: https://unicodeplus.com/U+2009 | |
const thinSpace = String.fromCharCode(8201); |
export class Cache<T extends object, K> { | |
items = new WeakMap<T, K>() | |
get<P extends T>(item: P, cb: (item: P) => K) { | |
if (!this.items.has(item)) { | |
this.items.set(item, cb(item)) | |
} | |
return this.items.get(item)! | |
} |
# TODO: Extract into it's own library | |
defmodule AbsintheSocket do | |
require Logger | |
alias Phoenix.Channels.GenSocketClient | |
@behaviour GenSocketClient | |
@control_topic "__absinthe__:control" | |
defdelegate fetch(term, key), to: Map | |
defdelegate get(term, key, default), to: Map |
import css from "rollup-plugin-css-porter"; | |
import pkg from "../../package.json"; | |
import resolve from "rollup-plugin-node-resolve"; | |
import babel from "rollup-plugin-babel"; | |
import path from "path"; | |
import commonjs from "rollup-plugin-commonjs"; | |
import { terser } from "rollup-plugin-terser"; | |
process.env.BABEL_ENV = "production"; | |
process.env.NODE_ENV = "production"; |
// This is a proper alternative to | |
// https://github.com/BuckleScript/bucklescript/blob/b9508105b1a35537bdea9a1fabd10f6c65f776b4/jscomp/bsb/templates/react-hooks/src/FetchedDogPictures/FetchedDogPictures.re#L14 | |
// The one in that file uses Promise, but that's *wrong*. | |
// We only used promise as a demo of its API. We'll remove it soon. | |
// As you can see below, the pure XMLHttpRequest code is just as clean, | |
// less mysterious for all, more performant, extensible, and actually correct. | |
// Ignore these externals for now. They're just for illustration | |
// purposes. I just copy pasted the Js code from |
async function doSomething() { | |
await timeout(2000); | |
} | |
function timeout(ms) { | |
return new Promise((res,rej) => setTimeout(rej,ms)); | |
} | |
Promise.race([ | |
doSomething(), | |
timeout(1000) |
const {useCallback, useEffect, useReducer, useRef} = require('react'); | |
let effectCapture = null; | |
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) { | |
let updateCounter = useRef(0); | |
let wrappedReducer = useCallback(function(oldWrappedState, action) { | |
effectCapture = []; | |
try { | |
let newState = reducer(oldWrappedState.state, action.action); |
These examples for:
[email protected]
and aboveflow-typed install # for initial run
animated.DialogOverlay = animated(DialogOverlay) | |
animated.DialogContent = animated(DialogContent) | |
function NewPostDialog({ date, show, onDismiss }) { | |
const rootRef = useRef(null) | |
const transitions = useTransition(show, null, { | |
from: { opacity: 0, y: -10, blur: 0 }, | |
enter: { opacity: 1, y: 0, blur: 8 }, | |
leave: { opacity: 0, y: -10, blur: 0 }, |
var appDomainURL = "*://app.owlandscroll.com/*"; | |
var appDomainURLCononical = "https://app.owlandscroll.com"; | |
const makeAppActive = () => { | |
chrome.tabs.query({ url: config.appDomainURL }, tabs => { | |
if (tabs.length) { | |
var tab = tabs[0]; | |
chrome.tabs.sendMessage(tab.id, { sendingUserToApp: true }, function( | |
response | |
) { |