This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type $Arguments<F> = $Call<<A: $ReadOnlyArray<mixed>>((...A) => mixed) => A, F>; | |
type $MethodArguments<O: {}, F: $Keys<O>> = $Arguments< | |
$NonMaybeType<$ElementType<O, F>>, | |
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Nice things about this approach: | |
- No need to expose $refs to users. Just use regular IDs instead. | |
- No need for double-composition (just compose React components, not queries). | |
- Composition becomes less magical (since we're passing regular IDs around). | |
- Collapse Query and Fragment concepts into Query. | |
- Take advantage of existing template strings to pass in query variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let called = false; | |
// this 'scope' is safe to interact with the React component, | |
// rendering and clicking as you please | |
await render( | |
<App | |
callback={() => { | |
called = true; | |
}} | |
/>, | |
document.body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Results of a few runs: | |
$ node ./index.js | |
{ | |
"a": 1000 | |
} | |
$ node ./index.js | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let {readFile} = require('fs') | |
let tally = {ab: 0, ba: 0} | |
let globalDone = 0 | |
let COUNT = 1000 | |
for (let x = 0; x < COUNT; x++) { | |
let result = '' | |
let done = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Option<T> = Some<T> | None | |
type Some<T> = { | |
flatMap<U>(f: (value: T) => None): None | |
flatMap<U>(f: (value: T) => Some<U>): Some<U> | |
flatMap<U>(f: (value: T) => Option<U>): Option<U> | |
getOrElse(value: T): T | |
} | |
type None = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Option<T>(value?: null | undefined): None | |
function Option<T>(value: T): Some<T> | |
function Option<T>(value?: T): Option<T> { | |
if (value == null) { | |
return new None | |
} | |
return new Some(value) | |
} | |
interface Option<T> { |
Using Webpack + Uglify + treeshaking + commonjs (not es2015).
Setup: https://github.com/bcherny/rxjs-filesize-repro
Package | import |
Size | Size (gzipped) |
---|---|---|---|
rxjs | Observable | 12kb | 3kb |
react | Component | 9kb | 4kb |
react-dom | render | 100kb | 33kb |
lodash | map | 20kb | 6kb |