#How to expose from DynamicModule something which will be created by FactoryProvider inside a Dynamic

1 messages · Page 1 of 1 (latest)

wintry prawn
#

Hi, all

I searched over the web but didn’t succeed to find any answer on my question.

I’m writing a NestJS Module. It has a registerAsync static method which accepts props some of which will be used to form a FactoryProvider, let’s call it FP1.
useFunction FP1 returns an options object, let’s call it O1.
That O1 object is needed for two things: 1) transform it somehow and the result should be used as a value of useValue property of a provider which my Module should expose, and 2) one property of options object O1 I want to use as a InjectioinToken of the provider which my Module should expose.

Any ideas on how I can do this? How to expose from DynamicModule something which will be created by FactoryProvider inside a Dynamic Module?

blissful briar
#

That's probably not possible. All exported injection tokens must be known synchronously (even with registerAsync - you'd have to pass it in top level options and not within useFactory).

What you can do is let the user pass in the token under which the dynamic value will be provided, but you can't asynchronously create the token itself.