2.49 kBSource Map (JSON)View Raw
1{"version":3,"file":"forward_ref.js","sourceRoot":"","sources":["../lib/forward_ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAe1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,YAA0B;IAC7C,YAAa,CAAC,eAAe,GAAG,UAAU,CAAC;IAC3C,YAAa,CAAC,QAAQ,GAAG;QAC7B,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,OAAwB,YAAa,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAS;IACzC,IAAI,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,eAAe,KAAK,UAAU,EAAE;QAC/G,OAAQ,IAAqB,EAAE,CAAC;KACjC;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport { stringify } from './facade/lang';\nimport { Type } from './facade/type';\n\n/**\n * An interface that a function passed into {@link forwardRef} has to implement.\n *\n * ### Example\n *\n * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref_fn'}\n * @experimental\n */\nexport interface ForwardRefFn {\n (): any;\n}\n\n/**\n * Allows to refer to references which are not yet defined.\n *\n * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of\n * DI is declared,\n * but not yet defined. It is also used when the `token` which we use when creating a query is not\n * yet defined.\n *\n * ### Example\n * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}\n * @experimental\n */\nexport function forwardRef(forwardRefFn: ForwardRefFn): Type<any> {\n (<any>forwardRefFn).__forward_ref__ = forwardRef;\n (<any>forwardRefFn).toString = function() {\n return stringify(this());\n };\n return <Type<any>>(<any>forwardRefFn);\n}\n\n/**\n * Lazily retrieves the reference value from a forwardRef.\n *\n * Acts as the identity function when given a non-forward-ref value.\n *\n * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))\n *\n * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}\n *\n * See: {@link forwardRef}\n * @experimental\n */\nexport function resolveForwardRef(type: any): any {\n if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') && type.__forward_ref__ === forwardRef) {\n return (type as ForwardRefFn)();\n } else {\n return type;\n }\n}\n"]}
\No newline at end of file