open-index/open-npm huggingface dataset:
npm package: @peerlancers/ngx-event-bus
Description: An angular 2+ library for event bus design pattern.
Latest version: 1.0.5

# NgxEventBus

> An angular library for dispatching event to easily communicate between component-component, service-component, and many more.

## Install

```bash
npm install @peerlancers/ngx-event-bus
```

or

```bash
yarn add @peerlancers/ngx-event-bus
```

## Usage

Installation
```typescript
import { EventBusModule } from '@peerlancers/ngx-event-bus';

@NgModule({
  imports: [
    EventBusModule.forRoot(),
  ]
})
```

Creation of custom event. Inherit the EventBusState class
```typescript
import { EventBusState } from '@peerlancers/ngx-event-bus';

export class ShowLoaderEvent extends EventBusState<void> {
  constructor() {
    super('ShowLoaderEvent');
  }
}
```

Register event listener
```typescript
import { Subscription } from 'rxjs';
import { EventBusDispatcherService } from '@peerlancers/ngx-event-bus';

export class EventClassSample {
  private _showLoaderHandler: Subscription;

  constructor(private _eventDispatcher: EventBusDispatcherService) {
    this._showLoaderHandler = this._eventDispatcher.addEventListener(
      new ShowLoaderEvent(), this._onShowLoader.bind(this)
    );
  }

  public ngOnDestroy(): void {
    if (this._showLoaderHandler) {
      this._showLoaderHandler.unsubscribe();
      this._showLoaderHandler = null;
    }
  }

  private _onShowLoader(): void {
    console.log('Show loader.');
  }
}
```
> Note don't forget to unsubscribe your handler, to prevent memory leak.

Dispatching an event
```typescript
import { EventBusDispatcherService } from '@peerlancers/ngx-event-bus';

export class EventClassSample {
  constructor(private _eventDispatcher: EventBusDispatcherService) {
    this._eventDispatcher.dispatch(new ShowLoaderEvent());
  }
}
```

## License

[MIT](http://vjpr.mit-license.org)

[npm-image]: https://img.shields.io/npm/v/live-xxx.svg
[npm-url]: https://npmjs.org/package/live-xxx
[travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
[travis-url]: https://travis-ci.org/live-js/live-xxx
[coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
[coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master
npm package: @peerlancers/ngx-logger
Description: An angular library for logging your classes such as service, components, directives, etc... for debugging purposes.
Latest version: 1.0.6

# NgxLogger

> An angular library for logging your classes such as service, components, directives, etc... for debugging purposes.

## Install

```bash
npm install @peerlancers/ngx-logger
```

or

```bash
yarn add @peerlancers/ngx-logger
```

## Usage

Installation
```bash
import { LoggerModule, LoggerConfig } from '@peerlancers/ngx-logger';

export function loggerConfig(cookieService: CookieService): LoggerConfig {
  let loggerFlag = cookieService.getEncryptedItem('enableLogger');
  return { enableLogging: loggerFlag || false } as LoggerConfig;
}

@NgModule({
  imports: [
    LoggerModule.forRoot(loggerConfig, [CookieService]),
  ]
})
```

For logging all class methods or properties use the LogClass() decorator.
```bash
import { LogClass } from '@peerlancers/ngx-logger';

@LogClass()
export class MyClass {

  public addNumbers(first: number, second: number): number {
    return first + second;
  }
}
```

For logging methods or properties use the LogMethod() decorator.
```bash
import { LogMethod } from '@peerlancers/ngx-logger';

export class MyClass {

  @LogMethod()
  public addNumbers(first: number, second: number): number {
    return first + second;
  }
}
```

If you want to ignore methods in a class logging
```bash
import { LogClass, LogIgnore } from '@peerlancers/ngx-logger';

@LogClass()
export class MyClass {

  @LogIgnore()
  public addNumbers(first: number, second: number): number {
    return first + second;
  }
}
```

## License

[MIT](http://vjpr.mit-license.org)

[npm-image]: https://img.shields.io/npm/v/live-xxx.svg
[npm-url]: https://npmjs.org/package/live-xxx
[travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
[travis-url]: https://travis-ci.org/live-js/live-xxx
[coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
[coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master