gmarcos87 / ionic2-ngrxstore-angularfire2 Goto Github PK
View Code? Open in Web Editor NEWSimple project: Ionic2 + Ngrx/store + AngularFire2
Simple project: Ionic2 + Ngrx/store + AngularFire2
This helped me, but why is product.service.ts in a folder called providers?
It's just a service, not a provider, isn't it?
Got the following error while testing this code. Maybe I am missing some changes in latest ionic updates? I am using Ionic 3.2.1, CLI 3, Angular 4.1.0.
ionic serve:
/src/effects/product.effects.ts, line: 35
Supplied parameters do not match any signature of call target.
product.effects.ts:
import {Injectable} from '@angular/core';
import {Effect, toPayload, Actions } from '@ngrx/effects';
import {Observable} from 'rxjs/Rx';
import 'rxjs/add/operator/mergeMap'
import {ProductService} from '../providers/product.service';
import {ProductI} from '../models/product.model';
import {ProductActions} from '../actions/product.actions';
@Injectable()
export class ProductEffects {
constructor(
private actions$: Actions,
private fb: ProductService,
private productActions: ProductActions
) { }
@Effect() allProduct$ = this.fb.getAll()
.map(product => { return this.productActions.loadProductSuccess(product)});
@Effect() changedProduct$ = this.fb.getChanges()
.map(change => {
if(change.event == 'child_removed'){
return this.productActions.deleteProductSuccess(change.product.$key);
}
else {
return this.productActions.addUpdateProductSuccess(change.product);
}
});
**@Effect({dispatch: false}) addProduct$ = this.actions$**
.ofType(ProductActions.ADD_PRODUCT)
.map<ProductI>(toPayload)
.switchMap(product => Observable.fromPromise(this.fb.add(product)));
@Effect() updateProducto$ = this.actions$
.ofType(ProductActions.UPDATE_PRODUCT)
.map<ProductI>(toPayload)
.mergeMap(product => this.fb.update(product));
@Effect({dispatch: false}) deleteProducto$ = this.actions$
.ofType(ProductActions.DELETE_PRODUCT)
.map<ProductI>(toPayload)
.mergeMap(product => this.fb.delete(product));
}
ionic info:
global packages:
@ionic/cli-utils : 1.1.2
Cordova CLI : 7.0.0
Ionic CLI : 3.1.2
local packages:
@ionic/app-scripts : 1.3.7
@ionic/cli-plugin-cordova : 1.1.2
@ionic/cli-plugin-ionic-angular : 1.1.2
Ionic Framework : ionic-angular 3.2.1
System:
Node : v6.10.3
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.