UNPKG

4.12 kBSource Map (JSON)View Raw
1{
2 "version": 3,
3 "file": "interface.js",
4 "sourceRoot": "",
5 "sources": [
6 "@uirouter/core/interface.ts"
7 ],
8 "names": [],
9 "mappings": ";;;AA6GA;IAAA;IAGA,CAAC;IADC,oCAAO,GAAP,UAAQ,MAAgB,IAAG,CAAC;IAC9B,yBAAC;AAAD,CAAC,AAHD,IAGC;AAHqB,gDAAkB",
10 "sourcesContent": [
11 "/**\n * # Core classes and interfaces\n *\n * The classes and interfaces that are core to ui-router and do not belong\n * to a more specific subsystem (such as resolve).\n *\n * @packageDocumentation\n */\n// Need to import or export at least one concrete something\nimport { noop } from './common/common';\nimport { UIRouter } from './router';\n\n/**\n * An interface for getting values from dependency injection.\n *\n * This is primarily used to get resolve values for a given token.\n * An instance of the `UIInjector` can be retrieved from the current transition using [[Transition.injector]].\n *\n * ---\n *\n * If no resolve is found for a token, then it will delegate to the native injector.\n * The native injector may be Angular 1 `$injector`, Angular 2 `Injector`, or a simple polyfill.\n *\n * In Angular 2, the native injector might be the root Injector,\n * or it might be a lazy loaded `NgModule` injector scoped to a lazy load state tree.\n */\nexport interface UIInjector {\n /**\n * Gets a value from the injector.\n *\n * For a given token, returns the value from the injector that matches the token.\n * If the token is for a resolve that has not yet been fetched, this throws an error.\n *\n * #### Example:\n * ```js\n * var myResolve = injector.get('myResolve');\n * ```\n *\n * #### ng1 Example:\n * ```js\n * // Fetch StateService\n * injector.get('$state').go('home');\n * ```\n *\n * #### ng2 Example:\n * ```js\n * import {StateService} from \"ui-router-ng2\";\n * // Fetch StateService\n * injector.get(StateService).go('home');\n * ```\n *\n * #### Typescript Example:\n * ```js\n * var stringArray = injector.get<string[]>('myStringArray');\n * ```\n *\n * ### `NOWAIT` policy\n *\n * When using [[ResolvePolicy.async]] === `NOWAIT`, the value returned from `get()` is a promise for the result.\n * The promise is not automatically unwrapped.\n *\n * @param token the key for the value to get. May be a string, a class, or any arbitrary object.\n * @return the Dependency Injection value that matches the token\n */\n get(token: any): any;\n /** Gets a value as type `T` (generics parameter) */\n get<T>(token: any): T;\n\n /**\n * Asynchronously gets a value from the injector\n *\n * For a given token, returns a promise for the value from the injector that matches the token.\n * If the token is for a resolve that has not yet been fetched, this triggers the resolve to load.\n *\n * #### Example:\n * ```js\n * return injector.getAsync('myResolve').then(value => {\n * if (value === 'declined') return false;\n * });\n * ```\n *\n * @param token the key for the value to get. May be a string or arbitrary object.\n * @return a Promise for the Dependency Injection value that matches the token\n */\n getAsync(token: any): Promise<any>;\n /** Asynchronously gets a value as type `T` (generics parameter) */\n getAsync<T>(token: any): Promise<T>;\n\n /**\n * Gets a value from the native injector\n *\n * Returns a value from the native injector, bypassing anything in the [[ResolveContext]].\n *\n * Example:\n * ```js\n * let someThing = injector.getNative(SomeToken);\n * ```\n *\n * @param token the key for the value to get. May be a string or arbitrary object.\n * @return the Dependency Injection value that matches the token\n */\n getNative(token: any): any;\n getNative<T>(token: any): T;\n}\n\nexport interface UIRouterPlugin extends Disposable {\n name: string;\n}\n\nexport abstract class UIRouterPluginBase implements UIRouterPlugin, Disposable {\n abstract name: string;\n dispose(router: UIRouter) {}\n}\n\nexport interface Disposable {\n /** Instructs the Disposable to clean up any resources */\n dispose(router?: UIRouter);\n}\n"
12 ]
13}
\No newline at end of file