Let me be more specific on how I want to use this.
I want to be able to create and instance of, lets say the
RESTCommunicationService, and
have
gridService = new GridService();
gridService.configure(new RESTCommunicationService()) // http is dependency
for the RESTCommunicationService
On Monday, October 2, 2017 at 7:25:23 PM UTC-7, Reza Razavipour wrote:
>
> I have an angular 4 application. I need to dynamically inject dependencies
> in my services or have customizable services.
>
> So currently I have a GridComponent with a GridService injected to it
>
> @Injectable()
>
> GridService...
>
>
> constructor(gridService: GridService)...
>
> What I need is to customize some behavior to the GridService.
> I want to have a GridService that makes http calls, or a GridService that
> uses websockets, etc... dynamically
>
> Code snippet to clarify.
>
> interface CommunicationService {
> }
>
> // an implementation that uses http
>
> class RESTCommunicationService implements CommunicationService {
> // needs to use Http
> }
>
> class WSCommunicationService implements CommunicationService {
> // needs something other than Http
> }
>
> at some place, may be in the AppComponent constructor,
> I want to be able to configure the GridService using something like
> configure (specializedService : CommunicationService)
>
> so when the GridComponent is injected GridService, all is setup to use
> http scheme or a different one.
>
> How would go about setting the service to allow for this customization?
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.