@isaiahiroko/ng-utils
v0.0.0
Published
A collection of common services for everyday angular application developemnt.
Downloads
2
Readme
NG Utils
Introduction
A collection of common services for everyday angular application developemnt.
Requirements
Install
$ npm i ng-utils
Available Services
Action Emitter
Summary
This service turns actions into stream of events that can be subscribed to. Serves as a companion to Angular built-in EventEmitter. EventEmitter is template-friendly, while ActionEmitter is @Injectables-friendly.
Sample Code
//file1.ts
import { ActionEmitter } from '@isaiahiroko/ng-utils'
@Component({
...
})
export class FireActions {
constructor (private actions: ActionEmitter) {
//fire an action
this.actions.emit({
type: '[SampleType]',
title: 'any title',
data: 'any data',
})
}
}
//file2.ts
import { ActionEmitter } from '@isaiahiroko/ng-utils'
@Component({
...
})
export class ReactToActions {
constructor (private actions: ActionEmitter) {
//listen to an action
this.actions.typeOf('[SampleType]').subscribe((action: any) {
//do sth with action
})
}
}