Skip to content

Instantly share code, notes, and snippets.

constructor(unsubscribe?: () => void) {
if (unsubscribe) {
(<any> this)._unsubscribe = unsubscribe;
}
}
constructor(unsubscribe?: () => void) {
if (unsubscribe) {
(<any> this)._unsubscribe = unsubscribe;
}
}
export interface SubscriptionLike extends Unsubscribable {
unsubscribe(): void;
readonly closed: boolean;
}
if (isFunction(_unsubscribe)) {
try {
_unsubscribe.call(this);
} catch (e) {
// some error logic
}
}
@GarryBrown
GarryBrown / movie.effect.ts
Created February 26, 2018 16:50
Simple effect to load data
import { Injectable } from '@angular/core';
import { Effect, Actions } from '@ngrx/effects';
import { of } from 'rxjs/observable/of';
import { map, switchMap, catchError } from 'rxjs/operators';
import * as fromRoot from '../../../app/store';
import * as movieActions from '../actions/movie.action';
import * as fromServices from '../../services';
@GarryBrown
GarryBrown / app.module.ts
Created February 26, 2018 16:42
Import Effects
import { EffectsModule } from '@ngrx/effects';
import { MovieEffects } from './effects/movie.effects';
@NgModule({
imports: [
...
EffectsModule.forRoot([MovieEffects])
]
})
export class AppModule {}