Created
April 11, 2018 08:53
-
-
Save confraria/5458fcec63394d5fdbed9458b3be5e64 to your computer and use it in GitHub Desktop.
sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Client, BasicAuth } from './core'; | |
import * as services from './services'; | |
export const serviceProviders: any = [ | |
{ provide: BasicAuth, useValue: new BasicAuth()}, | |
{ provide: Client, useFactory: factory.bind(Client), deps: [BasicAuth]} | |
].concat(Object.values(services).map(toProvider)) | |
function factory(dep) { | |
return new this(dep); | |
} | |
function toProvider(service) { | |
return { | |
provide: service, | |
useFactory: factory.bind(service), | |
deps: [Client] | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export { EventService } from '@c8y/client/lib/event'; | |
export { InventoryService } from '@c8y/client/lib/inventory'; | |
export { MeasurementService } from '@c8y/client/lib/measurement'; | |
export { AlarmService } from '@c8y/client/lib/alarm'; | |
export { OperationBulkService, OperationService } from '@c8y/client/lib/operation'; | |
export { ApplicationService } from '@c8y/client/lib/application'; | |
export { UserService } from '@c8y/client/lib/user'; | |
export { TenantService } from '@c8y/client/lib/tenant'; | |
export { SystemOptionsService } from '@c8y/client/lib/system-options'; | |
export { TenantOptionsService } from '@c8y/client/lib/tenant-options'; | |
export { TenantSecurityOptionsService } from '@c8y/client/lib/tenant-security-options'; | |
export { AuditService } from '@c8y/client/lib/audit'; | |
export { InventoryRoleService } from '@c8y/client/lib/inventory-role'; | |
export { DeviceRegistrationService, DeviceRegistrationBulkService } from '@c8y/client/lib/device-registration'; | |
export { UserRoleService } from "@c8y/client/lib/user-role"; | |
export { UserGroupService } from "@c8y/client/lib/user-group"; | |
export { Realtime } from '@c8y/client/lib/realtime'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule, Injectable } from '@angular/core'; | |
import { providers } from '@c8y/lib/providers' | |
import { AppStateService } from './app-state.service'; | |
import { ManagedObjectResolver } from './resolvers'; | |
@Injectable() { | |
class InventoryService {} // eventual future class extension | |
@NgModule({ | |
imports: [], | |
exports: [], | |
declarations: [], | |
providers: [ | |
AppStateService, | |
ManagedObjectResolver, | |
InventoryService, | |
].concat(providers) | |
}) | |
export class C8yDataModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { InventoryService } from '@c8y/client/services'; | |
@Component() | |
class MyComponent() { | |
constructor(inventory: InventoryService) {} | |
} | |
// after some time we need to create new classes just for angular for some reason by extending the orinal client class | |
// it's just a matter of replacing the import | |
import { InventoryService } from '@c8y/ng-data'; | |
@Component() | |
class MyComponent() { | |
constructor(inventory: InventoryService) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment