Skip to content

Instantly share code, notes, and snippets.

@confraria
Created April 11, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save confraria/008d63ca939085b50e4d141776ae5738 to your computer and use it in GitHub Desktop.
Save confraria/008d63ca939085b50e4d141776ae5738 to your computer and use it in GitHub Desktop.
sketch for single injectable
import { Client } from '@c8y/client';
@Component()
class MyComponent() {
constructor(client: Client) {}
}
import { NgModule, Injectable } from '@angular/core';
import { Client, BasicAuth } from '@c8y/client';
import { AppStateService } from './app-state.service';
import { ManagedObjectResolver } from './resolvers';
function clientFactory(auth) {
return new Client(auth);
}
@NgModule({
imports: [],
exports: [],
declarations: [],
providers: [
AppStateService,
ManagedObjectResolver,
InventoryService,
{ provide: BasicAuth, useValue: new BasicAuth() },
{ provide: Client, useFactory: clientFactory, deps: [BasicAuth] }
]
})
export class C8yDataModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment