Skip to content

Instantly share code, notes, and snippets.

@aaronblondeau
aaronblondeau / ApplicationState.js
Last active May 1, 2018 21:56
Application state refactored with observables to hold routes and an action to fetch them
import {observable, action} from 'mobx';
class ApplicationState {
@observable things = [];
@observable loading_things = false;
@observable things_error = "";
@action getThings() {
this.things = [];
this.loading_things = true;
@aaronblondeau
aaronblondeau / index.android.js
Last active August 26, 2017 19:18
Index with react-navigation
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React from 'react';
import {
AppRegistry
} from 'react-native';
@aaronblondeau
aaronblondeau / RideDetailScreen.js
Created June 29, 2017 21:58
Initial version of where2ride ride detail screen
import React, { Component } from 'react';
import {
StyleSheet,
} from 'react-native';
import { Container, Content, Button, Text, Icon } from 'native-base';
import {observer} from 'mobx-react';
import applicationState from '../ApplicationState'
import { NavigationActions } from 'react-navigation'
@aaronblondeau
aaronblondeau / HomeScreen.js
Last active August 26, 2017 19:15
Initial version of where2ride home screen component
import React, { Component } from 'react';
import {
StyleSheet,
} from 'react-native';
import { Container, Content, Button, Text } from 'native-base';
import {observer} from 'mobx-react';
import applicationState from '../ApplicationState'
@observer
@aaronblondeau
aaronblondeau / index.android.js
Created June 29, 2017 21:46
where2ride home screen updated to utilize application state.
/**
* where2ride React Native App
* https://github.com/aaronblondeau/where2ride
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
} from 'react-native';
@aaronblondeau
aaronblondeau / ApplicationState.js
Created June 29, 2017 21:43
Initial version of where2ride app state (with MobX)
import {observable} from 'mobx';
class ApplicationState {
@observable clicks = 0;
}
const state = new ApplicationState()
export default state
@aaronblondeau
aaronblondeau / .babelrc
Created June 29, 2017 21:40
where2ride .babelrc file to allow MobX decorators.
{
"presets": ["react-native"],
"plugins": ["transform-decorators-legacy"]
}
@aaronblondeau
aaronblondeau / index.android.js
Last active August 26, 2017 18:59
React Home Screen with NativeBase button
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet
@aaronblondeau
aaronblondeau / promise_coroutine_loop.js
Created August 20, 2016 15:35
Example of Promise.coroutine with a loop
var Promise = require('bluebird');
var request = require('request');
var fs = require('fs');
request_promise = Promise.promisify(request);
writeFile_promise = Promise.promisify(fs.writeFile);
Promise.coroutine(function* () {
try {
@aaronblondeau
aaronblondeau / promise_coroutine.js
Created August 20, 2016 15:34
Example of Bluebird's Promise.coroutine
var Promise = require('bluebird');
var request = require('request');
var fs = require('fs');
request_promise = Promise.promisify(request);
writeFile_promise = Promise.promisify(fs.writeFile);
Promise.coroutine(function* () {
try {