react + redux + RR
It uses https://gist.github.com/iNikNik/3c1b870f63dc0de67c38 for stores and actions.
1) create redux
const redux = createRedux(state);2) get requireAccess func => bindCheckAuth to redux
| // Here is a function that I use all the time when creating public | |
| // async APIs in JavaScript: | |
| const resolvePromise = (promise, callback) => { | |
| if (callback) | |
| promise.then(value => callback(null, value), callback) | |
| return promise | |
| } | |
| // Sometimes I like to use callbacks, but other times a promise is |
| import React from 'react'; | |
| const toPromise = (load) => (new Promise((resolve) => ( | |
| load(resolve) | |
| ))); | |
| class LazilyLoad extends React.Component { | |
| constructor() { | |
| super(...arguments); |
| import * as Ensure from '../../../../utils/lib/Ensure' | |
| import markdownBlockDelimiter from './markdownBlockDelimiter' | |
| import {BlockTypes, BlockTypeRegExps} from './Types' | |
| import { | |
| CharacterMetadata, | |
| ContentState, | |
| ContentBlock, | |
| EditorState, | |
| genKey, | |
| } from 'draft-js' |
| #!/usr/bin/env python | |
| # This is a trick, to output the bash commands we need to run in shell, and just execute this script inside an eval within our shell, so it imports what we need | |
| # Possibly tie this in with https://gist.github.com/mbainter/b38a4cb411c0b5c1bae6 for MFA support | |
| # Will need to durably store MFA access tokens, possibly in some other env vars | |
| # Could also store all different keys/info in different vars, to reuse as needed (lots of env vars though, file may be better) | |
| import os | |
| import sys | |
| import getpass |
| if ( | |
| process.env.NODE_ENV === 'production' && | |
| window.__REACT_DEVTOOLS_GLOBAL_HOOK__ && | |
| Object.keys(window.__REACT_DEVTOOLS_GLOBAL_HOOK__._renderers).length | |
| ) { | |
| window.__REACT_DEVTOOLS_GLOBAL_HOOK__._renderers = {} | |
| } |
| /** | |
| * Required Variables. | |
| */ | |
| variable "name" {} | |
| variable "port" {} | |
| variable "elb_security_group" {} | |
| variable "elb_subnets" {} |
| #!/bin/bash | |
| # This script can be used in "run & hope" mode or you can use it as a recipe to | |
| # do things manually - you probably want the latter if you really care about | |
| # the data in your databases. | |
| # Happy hacking | |
| # /Eoin/ | |
| # Tell bash to stop if something goes wrong | |
| set -e |
| // Observable is an Union Type, with the following variants | |
| const Empty = () => ['EMPTY'] | |
| const Cons = (head, tail) => ['CONS', head, tail] | |
| const Future = promise => ['FUTURE', promise] | |
| // race between 2 promises; each promise will resolve to a lazy value | |
| const lazyRace = (p1, p2) => Promise.race([p1,p2]).then(lazy => lazy()) | |
| // function composition | |
| const compose = (...fns) => (arg) => fns.reduceRight((res, f) => f(res), arg) |
react + redux + RR
It uses https://gist.github.com/iNikNik/3c1b870f63dc0de67c38 for stores and actions.
1) create redux
const redux = createRedux(state);2) get requireAccess func => bindCheckAuth to redux
Why would you want to do this? Because you often don't need more. It's nice to not have to think about your "router" as this big special thing.
Instead, with this approch, your app's current pathname is just another piece of state, just like anything else.
This also means that when doing server-side rendering of a redux app, you can just do:
var app = require('your/redux/app')
var React = require('react')