by
3 7
0
3
233
1
Top 10% !
Popular
Specified
No tags for this snippet yet.
Languagecsharp
LanguageJavaScript
SourceGitHub

flow libdef for found

flow libdef for found: 
found.js
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1846708/flow-libdef-for-found?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// @flow // WARNING: this is early and mostly unused. As I'm refactoring code I'll try to update this. ping me with questions. declare module 'found' { declare type Map = { [key: string]: any } /** * The shape might be different with a custom matcher or history enhancer, but the default matcher * assumes and provides this shape. As such, this validator is purely for user convenience and * should not be used internally. */ declare export type Match = { location: { pathname: string, query: Map, }, params: Map, } /** * An object implementing the matching algorithm. * * User code generally shouldn't need this, but it doesn't hurt to export here, since we use it * for routerShape below. */ declare export type Matcher = { match: Function, getRoutes: Function, isActive: Function, /** * Returns the path string for a pattern of the same format as a route path and a object of the * corresponding path parameters */ format: (pattern: any, params: Map) => any, } /** * Location descriptor string: * store.dispatch(FarceActions.push('/foo?bar=baz#qux')); * * Equivalent location descriptor object: * store.dispatch(FarceActions.push({ * pathname: '/foo', * search: '?bar=baz', * hash: '#qux', * })); * * https://github.com/4Catalyzer/farce#locations-and-location-descriptors */ declare export type Location = { /** * 'PUSH' or 'REPLACE' if the location was reached via FarceActions.push or FarceActions.replace respectively; * 'POP' on the initial location, or if the location was reached via the browser back or forward buttons or * via FarceActions.go */ action: 'PUSH' | 'REPLACE' | 'POP', /** * the path name; as on window.location e.g. '/foo' */ pathname: string, /** * the search string; as on window.location e.g. '?bar=baz' */ search: string, /** * the location hash; as on window.location e.g. '#qux' */ hash: string, /** * if present, a unique key identifying the current history entry */ key?: string, /** * the current index of the history entry, starting at 0 for the initial entry; this increments * on FarceActions.push but not on FarceActions.replace */ index: number, /** * the difference between the current index and the index of the previous location */ delta: number, /** * additional location state that is not part of the URL */ state: any, /** * map version of search string */ query: Map } /** * Lenient arg version of location using in #push and #replace. */ declare export type LocationArg = string | { pathname: string, search?: string, hash?: string, state?: any, query?: Map } /** * The transition hook function receives the location to which the user is attempting to navigate. * * This function may return: * - true to allow the transition * - false to block the transition * - A string to prompt the user with that string as the message * - A nully value to call the next transition hook and use its return value, if present, or * else to allow the transition * - A promise that resolves to any of the above values, to allow or block the transition * once the promise resolves * * @see https://github.com/4Catalyzer/farce#transition-hooks */ declare export type TransitionHook = (location: Location) => ?(boolean | string | Promise<?(boolean | string)>) declare export class Router { /** * Navigates to a new location * @see farce */ push: (location: LocationArg) => void, /** * Replace the current history entry * @see farce */ replace: (location: LocationArg) => void, /** * Moves delta steps in the history stack * @see farce */ go: (delta: number) => void, createHref: Function, createLocation: Function, /** * for match as above, returns whether match corresponds to location or a subpath of location; * if exact is set, returns whether match corresponds exactly to location */ isActive: (match: Match, location: Location, options: {exact?: boolean}) => boolean, matcher: Matcher, /** * Adds a transition hook that can block navigation. * * This method takes a transition hook function and returns a function to remove the transition hook. */ addTransitionHook: (hook: TransitionHook) => (() => void), } declare export class Route { Component: Function children?: Array<Route> getComponent?: (props: RoutingState) => Promise<Function> path?: string render?: (args: RenderArgs) => Function prepareParams?: (params: Map, match: Match) => Map queries?: { [key: string]: Function } } declare export type RoutingState = { /** * The current location */ location: Location, /** * The union of path parameters for all matched routes */ params: Map, /** * An array of all matched route objects */ routes: Array<Route>, /** * The route object corresponding to this component */ route: Route, /** * the path parameters for route */ routeParams: Map, router: Router, /** * an object with location and params as properties */ match: Match, /** * an object with static router properties */ router: Router } /** * @see https://github.com/4Catalyzer/found/blob/master/README.md#route-configuration * A bit lower for the list, no anchor there */ declare export type RenderArgs = { match: Match, /** * the component for the route, if any; null if the component has not yet been loaded */ Component?: Function, /** * the default props for the route component, specifically match with data as an additional property; * null if data have not yet been loaded */ props?: RoutingState, /** * the data for the route, as above; null if the data have not yet been loaded */ data?: any } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus