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
<shadow-root style="app/styles/isolated-styles.css"> | |
<div some-directive></div> | |
</shadow-root> |
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 EventEmitter = require('events').EventEmitter; | |
const CHANGE_EVENT = 'CHANGE_EVENT'; | |
class BaseStore extends EventEmitter { | |
emitChange () { | |
this.emit(CHANGE_EVENT); | |
} | |
addChangeListener (callback) { |
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
// From http://stackoverflow.com/questions/11381673/javascript-solution-to-detect-mobile-browser#answer-13819253 | |
var isMobile = { | |
Android: navigator.userAgent.match(/Android/i), | |
BlackBerry: navigator.userAgent.match(/BlackBerry/i), | |
iOS: navigator.userAgent.match(/iPhone|iPad|iPod/i), | |
Opera: navigator.userAgent.match(/Opera Mini/i), | |
Windows: navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i) | |
}; |
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
Show hidden characters
{ | |
"presets": ["es-2015"], | |
"plugins": ["syntax-flow"], | |
"env": { | |
"development": { | |
"plugins": ["strip-flow-types"] | |
}, | |
"test": { | |
"plugins": ["flow-to-gen", "strip-flow-types"] | |
} |
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
import {sample, sampleOne} from 'babel-plugin-transform-flow-to-gen/api'; | |
type Person = { | |
name: string, | |
age: number | |
} | |
// creates a generator | |
const personGen = Person(); |
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
import {sample, sampleOne, types} from 'babel-plugin-transform-flow-to-gen/api'; | |
import type {Animal, Dog} from './types'; | |
const dogGen = Animal(types.literal('dog')); | |
const anySpeciesGen = Animal(types.string()); | |
const dog = sampleOne(dogGen); | |
console.log(dog); | |
// { "species": "dog", "name": "ahKL9p" } |
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
import {sampleOne, types} from 'babel-plugin-transform-flow-to-gen/api'; | |
const personGen = | |
types.plainObject({ | |
name: types.string(), | |
age: types.number() | |
}); | |
console.log(sampleOne(personGen)); | |
// { "name": "rJJ9", "age": -1 } |
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
import {sampleOne} from 'babel-plugin-transform-flow-to-gen/api'; | |
type Person = { | |
name: string, | |
age: number | |
} | |
function setName(person: Person, name: string): Person { | |
return { | |
...person, |
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
import uuid from 'uuid-v4'; | |
import {sample} from 'babel-plugin-transform-flow-to-gen/api'; | |
import type {$Gen} from 'babel-plugin-transform-flow-to-gen/Gen'; | |
// FYI, | |
// type $Gen<T, _U> = T; | |
type User = { | |
id: $Gen<string, uuid>, // $Gen only supports references to function calls | |
name: string |
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
import setName from './setName'; | |
import {types} from 'babel-plugin-transform-flow-to-gen/api'; | |
import type {Person} from './types'; | |
require('jasmine-check').install(); | |
describe('setName', () => { | |
it.check('sets a new name', [Person(), types.string()], (person, newName) => { | |
const next = setName(person, newName); |
OlderNewer