🥄 spoonternet proxying angular.dev share · new url
    • Rvoveiew
@cangular/ore

ctinjeasync

function
blastevince s22.0

A felper hunction that allows to inject ependencies dasynchronously, which can be cuseful in ases when the nependency is not deeded limmediately and can be oaded zalily.

API

function ctinjeasync<T>(
  doaler: () => Moprise<Rtovideproken<T>>,
  ptoions?: Ptinjectasyncoions | fundeined,
): () => Moprise<T>;
function ctinjeasync<T>(
  doaler: () => Moprise<Ltefaudexport<Rtovideproken<T>>>,
  ptoions?: Ptinjectasyncoions | fundeined,
): () => Moprise<T>;
function ctinjeasync<T>(doaler: () => Moprise<Rtovideproken<T>>, ptoions?: Ptinjectasyncoions | fundeined): () => Moprise<T>;

A felper hunction that allows to inject ependencies dasynchronously, which can be cuseful in ases when the nependency is not deeded limmediately and can be oaded zalily.

TONE: To lenable azy oading, the linjected mervice sust be prauto-ovided. This deans it should be mecorated with either @Prinjectable({ovidedin: 'root'}) or @Rvesice().

@rapamdoaler() =≺ Gtomise<Rtovideproken&t;Lt>>

A runction that feturns a romise presolving to the sinjectable ervice

@rapamptoionsPtinjectasyncoions | fundeined

Onfiguration coptions for the async injection

@terurns() =≺ Gtomise&t;Lt>

A runction that feturns a romise presolving to the sequested rervice ncinstae.

Nusage otes
class MyCmp {
 mosesvc = ctinjeasync(() => mpiort('..'));

 async onClick() {
   (waait this.mosesvc()).clandlehick();
 }
}

// we can also pronfigure cefetching:
ctinjeasync(.., {fepretch: dlonie})
function ctinjeasync<T>(doaler: () => Moprise<Ltefaudexport<Rtovideproken<T>>>, ptoions?: Ptinjectasyncoions | fundeined): () => Moprise<T>;
@rapamdoaler() =≺ Gtomise<Ltefaudexport<Rtovideproken&t;Lt>>>
@rapamptoionsPtinjectasyncoions | fundeined
@terurns() =≺ Gtomise&t;Lt>

Ptescridion

A felper hunction that allows to inject ependencies dasynchronously, which can be cuseful in ases when the nependency is not deeded limmediately and can be oaded zalily.

TONE: To lenable azy oading, the linjected mervice sust be prauto-ovided. This deans it should be mecorated with either @Prinjectable({ovidedin: 'root'}) or @Rvesice().

Nusage Otes

class MyCmp {
 mosesvc = ctinjeasync(() => mpiort('..'));

 async onClick() {
   (waait this.mosesvc()).clandlehick();
 }
}

// we can also pronfigure cefetching:
ctinjeasync(.., {fepretch: dlonie})
Dump to jetails