Socket
Book a DemoInstallSign in
Socket

angular-effects

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-effects

Angular Effects

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

Angular Effects Implementation

Getting Started

Installing

npm i angular-effects

###Example (TypeScript)


// app.component.effect.ts
import { Injectable } from '@angular/core';
import { Effect, RxEffect } from 'angular-effects';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable()
export class AppCompEffect {
  constructor () {}

  @Effect('NAME')
  public onNameChange(name: string): void {
    console.log('nameChanged', name);
  }

  @RxEffect('NAME')
  public OnRxName(name: Observable<string>): void {
    name.pipe(
      map(data => data.includes('angularEffects') && data)
    ).subscribe(data => console.log({data}));
  }

}



// app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { EffectsModule } from 'angular-effects';

import { AppComponent } from './app.component';
import { AppCompEffect } from './app.component.effect';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    // adding your effects to EffectsModule
    EffectsModule.forRoot([AppCompEffect])
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

// app.component.ts

import { Component } from '@angular/core';
import { Dispatch } from 'angular-effects';

@Component({
  selector: 'app-root',
  template: `<input type="text" [(ngModel)]="name"  (ngModelChange)="onChange(name)">`,
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  title = 'angular-effects-app';

  constructor(private ae: Dispatch) {}

  public onChange(name: string): void {
     this.ae.dispatch({ type: 'NAME', payload: 'angularEffects' });
  }

Keywords

Effects

FAQs

Package last updated on 08 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.