UNPKG

1.41 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Type } from './facade/type';
9/**
10 * An interface that a function passed into {@link forwardRef} has to implement.
11 *
12 * ### Example
13 *
14 * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref_fn'}
15 * @experimental
16 */
17export interface ForwardRefFn {
18 (): any;
19}
20/**
21 * Allows to refer to references which are not yet defined.
22 *
23 * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
24 * DI is declared,
25 * but not yet defined. It is also used when the `token` which we use when creating a query is not
26 * yet defined.
27 *
28 * ### Example
29 * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
30 * @experimental
31 */
32export declare function forwardRef(forwardRefFn: ForwardRefFn): Type<any>;
33/**
34 * Lazily retrieves the reference value from a forwardRef.
35 *
36 * Acts as the identity function when given a non-forward-ref value.
37 *
38 * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
39 *
40 * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
41 *
42 * See: {@link forwardRef}
43 * @experimental
44 */
45export declare function resolveForwardRef(type: any): any;