This file contains hidden or 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 Rx from 'rx' | |
| import request from 'superagent' | |
| export function getCurrentPosition(geolocationOptions = {enableHighAccuracy: true, timeout: 8000}) { | |
| if (!window.navigator && !window.navigator.geolocation) { | |
| throw new TypeError('geolocation not available') | |
| } | |
| return new Rx.AnonymousObservable((observer) => { |
This file contains hidden or 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
| /** | |
| Smoothly scroll element to the given target (element.scrollTop) | |
| for the given duration | |
| Returns a promise that's fulfilled when done, or rejected if | |
| interrupted | |
| */ | |
| var smoothScroll = function(element, target, duration) { | |
| target = Math.round(target); | |
| duration = Math.round(duration); |
This file contains hidden or 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
| // side effects | |
| const http = require('http') | |
| const hostname = '127.0.0.1' | |
| const port = 1337 | |
| http.createServer(httpEffect.serverCallback) | |
| .listen(port, hostname, () => { | |
| console.log(`Server running at http://${hostname}:${port}/`) | |
| }); |
This file contains hidden or 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
| walk([dir, []]) | |
| .then(all => console.log('all', all)) | |
| .catch(err => console.error('err', err)) | |
| function readdir(directory) { | |
| return new Promise((accept, reject) => { | |
| fs.readdir(directory, (err, files) => { | |
| if (err) reject(err) | |
| accept(files) | |
| }) |
This file contains hidden or 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
| export const moviesSelector = ({ movies }) => movies.movies |
This file contains hidden or 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
| // foldp : (a -> state -> state) -> state -> Signal a -> Signal b | |
| var foldp = (updateFunction) => (defaultState) => (signal) => | |
| updateFunction(defaultState)(signal) | |
| const INCREMENT = 'INCREMENT' | |
| const DECREMENT = 'DECREMENT' | |
| const Actions = { | |
| increment: () => ({ type: INCREMENT }), |
This file contains hidden or 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 React, { Component } from 'react' | |
| import { view as CommentsList } from './components/CommentsList' | |
| class Container extends Component { | |
| render() { | |
| return ( // would I put the <Loading/> component here or within the presentational component? | |
| // as I might include more 'container' components within here, I'd put the <Loading/> component here *once*, | |
| // and let the presentational components just render their own stuff. |
This file contains hidden or 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
| const dogRoute = { | |
| path: ':dogId', | |
| view, | |
| init, | |
| update, | |
| childRoutes: [] | |
| } | |
| const dogsRoute = { |
This file contains hidden or 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 R from 'ramda' | |
| const runTask = R.curry((taskList, deadline) => { | |
| while ((deadline.timeRemaining() > 0 || deadline.didTimeout) && taskList.length) { | |
| const task = taskList.shift() | |
| task() | |
| } | |
| if (taskList.length) { |
This file contains hidden or 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 R from 'ramda' | |
| const defaultConfig = (config = {}) => { | |
| const { | |
| localStorage: storage = { removeItem: R.F }, | |
| __APP_VERSION__: version = '', | |
| } = __BROWSER__ ? window : {} | |
| const namespace = 'my-cool-app' | |
| const appName = `${namespace}.v${version}` |