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 interface Action<T = any, K extends keyof T= any> { | |
| type: K; | |
| payload: T[K]; | |
| } | |
| /////////////////////////////////////////////////////////// | |
| import { Stream, mergeArray } from 'most'; | |
| import { Action } from './types'; | |
| import { async } from 'most-subject'; |
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
| /* | |
| - storeとつながる | |
| - selectorをstreamで書ける | |
| */ | |
| import { h, Component, ComponentConstructor, FunctionalComponent } from 'preact'; | |
| import { Stream, Subscription, from, mergeArray } from 'most'; | |
| import { async } from 'most-subject'; | |
| import { Store } from 'redux'; | |
| import { noop } from '@utils'; |
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 { h, Component, ComponentConstructor, FunctionalComponent } from 'preact'; | |
| import { Stream, Subscription, mergeArray } from 'most'; | |
| import { noop, hasOwn } from '@utils'; | |
| export type AnyComponent<P> = ComponentConstructor<P, any> | FunctionalComponent<P>; | |
| export type StreamableProps<P> = { | |
| [K in keyof P]: Stream<P[K]> | P[K] | |
| }; |
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 { MiddlewareAPI, Middleware, Dispatch } from 'redux'; | |
| import { async } from 'most-subject'; | |
| import { mergeArray, Stream } from 'most'; | |
| import enhance, { EnhancedStore } from './make-typed-dispatch'; | |
| export interface Action<T = any, K extends keyof T = any> { | |
| type: K; | |
| payload: T[K]; | |
| } |
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 { MiddlewareAPI } from 'redux'; | |
| export type EnhancedStore<T, A> = T & { | |
| dispatch: <K extends keyof A>(type: K, payload: A[K]) => { | |
| type: K, payload: A[K] | |
| } | |
| }; | |
| export default function makeTypedDispatch<T extends MiddlewareAPI<any>, A>(store: T): EnhancedStore<T, A> { | |
| const origin = store.dispatch; |
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 { MiddlewareAPI, Middleware, Dispatch } from 'redux'; | |
| import { async } from 'most-subject'; | |
| import { mergeArray, Stream } from 'most'; | |
| import Dispatcher from '@cotto/dispatcher'; | |
| import { noop } from './utils'; | |
| interface RequireCtx { | |
| dispatcher: Dispatcher; | |
| } |
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 { h, Component, ComponentConstructor, FunctionalComponent } from 'preact'; | |
| import { Stream, mergeArray, Subscription } from 'most'; | |
| type AnyComponent<P> = ComponentConstructor<P, any> | FunctionalComponent<P>; | |
| export interface Action<T = any, K extends keyof T= any> { | |
| type: K; | |
| payload: T[K]; | |
| } |
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 interface Action<T = any, K extends keyof T = any> { | |
| type: K; | |
| payload: T[K]; | |
| } | |
| export type MapAction<T = any> = { | |
| [K in keyof T]: Action<T, K> | |
| }; | |
| export type MapActionHandler<S, A extends MapAction> = { |
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
| interface CurriedFunction2<A, B, C> { | |
| (): CurriedFunction2<A, B, C>; | |
| (a: A): (b: B) => C; | |
| (a: A, b: B): C; | |
| } | |
| interface CurriedFunction3<A, B, C, D> { | |
| (): CurriedFunction3<A, B, C, D>; | |
| (a: A): CurriedFunction2<B, C, D>; | |
| (a: A, b: B): (c: C) => D; |
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 { Component } from 'preact'; | |
| export interface Props { | |
| cond: boolean | ((prevProps: any) => boolean); | |
| [K: string]: any; | |
| } | |
| export default class ShouldChildrenUpdate extends Component<Props, void> { | |
| prevProps: any = this.props; | |
| shouldComponentUpdate(nextProps: Props) { |