angular2
Version:
Angular 2 - a web framework for modern web apps
40 lines (39 loc) • 1.3 kB
TypeScript
import { Type } from 'angular2/src/facade/lang';
/**
* An interface that a function passed into {@link forwardRef} has to implement.
*
* ### Example
*
* {@example core/di/ts/forward_ref/forward_ref.ts region='forward_ref_fn'}
*/
export interface ForwardRefFn {
(): any;
}
/**
* Allows to refer to references which are not yet defined.
*
* For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
* DI is declared,
* but not yet defined. It is also used when the `token` which we use when creating a query is not
* yet defined.
*
* ### Example
* {@example core/di/ts/forward_ref/forward_ref.ts region='forward_ref'}
*/
export declare function forwardRef(forwardRefFn: ForwardRefFn): Type;
/**
* Lazily retrieves the reference value from a forwardRef.
*
* Acts as the identity function when given a non-forward-ref value.
*
* ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
*
* ```typescript
* var ref = forwardRef(() => "refValue");
* expect(resolveForwardRef(ref)).toEqual("refValue");
* expect(resolveForwardRef("regularValue")).toEqual("regularValue");
* ```
*
* See: {@link forwardRef}
*/
export declare function resolveForwardRef(type: any): any;