1: rxjs, history-async
- video
- repo
2: react
- video
- repo
3: redux & react-redux
- video
import { makeADT, ADTType, ofType } from '@morphic-ts/adt' | |
import { combineReducers } from 'redux-immutable'; | |
import { Action, createStore, Reducer } from 'redux'; | |
import * as Immutable from 'immutable' | |
interface Ignition { type: 'Ignition' } | |
interface Accelerate { type: 'Accelerate' } | |
interface Brake { type: 'Brake' } | |
const AppAction = makeADT('type')({ |
import * as O from 'fp-ts/lib/Option' | |
import * as A from 'fp-ts/lib/Array' | |
import { sequenceS } from 'fp-ts/lib/Apply' | |
import { pipe } from 'fp-ts/lib/pipeable' | |
interface Money { currency: Currency; amount: number } | |
type PricingInfo = { effectiveDate: Date; price: Money; ticker: string } | |
enum Currency { USD = "USD", EUR = "EUR", JPY = "JPY", CHF = "CHF", GBP = "GBP", CAD = "CAD", AUD = "AUD", } |
import { pipe } from 'fp-ts/lib/pipeable' | |
import * as L from 'monocle-ts/lib/Lens' | |
import * as Op from 'monocle-ts/lib/Optional' | |
import { makeADT, ofType, ADTType } from '@morphic-ts/adt' | |
interface Bicycle { | |
type: 'Bicycle' | |
color: string | |
} |
import serialize from 'serialize-javascript'; | |
import path from 'path'; | |
import fs from 'fs'; | |
import React from 'react'; | |
import ReactDOMServer from 'react-dom/server'; | |
export default <P>( | |
App: React.ReactElement<P>, | |
globalState: string | undefined, | |
): Promise<string> => new Promise((resolve, reject) => { |
import { Reducer, Action } from "redux"; | |
import { ADT } from '@morphic-ts/adt'; | |
export const safeReducer = <A extends Action, S, tag extends keyof A & string>( | |
curriedReducer: (a: A) => (s: S) => S, | |
defaultState: S, | |
adt: ADT<A, tag> | |
): Reducer<S, A> => ( | |
nullableState, | |
action |
1: rxjs, history-async
2: react
3: redux & react-redux
{ | |
"Opaque ADT": { | |
"prefix": "oadt", | |
"body": [ | |
"export const $1ADT = makeADT('type')({$2});", | |
"export type $1ADT = ADTType<typeof $1ADT>", | |
"export interface $1 extends Newtype<{ readonly $1: unique symbol }, $1ADT> {}", | |
"export const $1 = iso<$1>()" | |
], | |
"description": "Defines an opaque ADT" |
/** taken from https://aws-amplify.github.io/docs/js/authentication */ | |
import { AsyncStorage } from '@react-native-community/async-storage'; | |
import { Auth } from '@aws-amplify/auth'; | |
const MEMORY_KEY_PREFIX = '@MyStorage:'; | |
let dataMemory = {}; | |
/** @class */ | |
class MyStorage { | |
static syncPromise = null; |