1: rxjs, history-async
- video
- repo
2: react
- video
- repo
3: redux & react-redux
- video
| /** 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; |
| { | |
| "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" |
1: rxjs, history-async
2: react
3: redux & react-redux
| 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 |
| 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 { 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 * 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 { 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')({ |
| interface PrintAdverb<T> { | |
| then: <TResult1>(o: ((value: T) => PrintAdverb<TResult1>)) => PrintAdverb<TResult1>; | |
| absolutely?: string; | |
| positively?: string; | |
| veryvery?: string; | |
| necessary?: string; | |
| } | |
| const pa: PrintAdverb<string> = { | |
| then: <TResult1>(o: ((value: string) => PrintAdverb<TResult1>)) => o('3') | |
| } |
| import { pipe } from 'fp-ts/pipeable' | |
| import * as O from 'fp-ts/Option' | |
| import * as Op from 'monocle-ts/lib/Optional' | |
| import * as r from 'rxjs' | |
| import * as ro from 'rxjs/operators' | |
| import { createStore, applyMiddleware } from 'redux'; | |
| import { createEpicMiddleware } from 'redux-observable'; | |
| import React from 'react'; | |
| import { Provider, useDispatch, useSelector } from 'react-redux'; | |
| import { makeADT, ofType, ADTType } from '@morphic-ts/adt' |