0.0.3 • Published 6 years ago

@bayamsell/ng-core v0.0.3

Weekly downloads
-
License
-
Repository
gitlab
Last release
6 years ago

BayamSell Core

This library was generated with Angular CLI version 8.2.0.

Getting started

Working with this library is quit simple.

Install and use all

  • First run the following command in your terminal

npm i @bayamsell/ng-core

to add this library to your angular project

  • Then import the BayCoreModule with forRoot in your AppModule.ts and the HttpClientModule module, like
// Initialize global configurations
const config = new ModuleConfig();
// Customizing the root parameter for the backend endpoint
config.customParams.rootUrl = environment.backendUrl;

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule, // <-- Import it to use HttpClient methods without any harm
    BayCoreModule.forRoot(config) // <--- Import it using forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
}

The HttpClientModule is to be able to use the app without any harm, as there's a lot of services working in background

If you use SharedModules, you may want to import just BayCoreModule (without the forRoot) and the HttpClientModule module. Like

@NgModule({
  declarations: [],
  imports: [
    CommonModule,
    HttpClientModule,
    BayCoreModule,
  ],
  exports: [
    CommonModule,
    HttpClientModule,
    BayCoreModule,
  ]
})
export class SharedModule {
}
  • Then just import anything you'll like to use where you want it to be, as BayCoreModule does import everything as root elements.

Example:

import {Component, OnInit} from '@angular/core';
import {
  AnalyticsService,
  Announce,
  AnnouncesService,
  LatLng,
  MapsService,
  Shop,
  ShopsService,
  UnSubscriber,
  User,
  UsersService
} from '@bayamsell/ng-core';

... // Other imports...

export class AnnounceComponent extends UnSubscriber implements OnInit {

  announce: Announce;
  shop: Shop;
  provider: User;
  latLng: LatLng;

  constructor(
    protected analyticsService: AnalyticsService,
    protected activatedRoute: ActivatedRoute,
    protected announcesService: AnnouncesService,
    protected usersService: UsersService,
    protected shopsService: ShopsService,
    protected mapsService: MapsService,
  ) {
    super();
  }
    
  ... // Other class members...

}

Use it as singletons

You may want at a certain time to use all these services but just as a singleton, each one in each module, or import it manually yourself. Simple, just import it, without using the BayCoreModule

Remember thought:

  • you may have too import it in a module before using it in that module;
  • Certain services or modules depends each from others (like the AuthService)
0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago