Commit 38a2aab3 authored by prumde's avatar prumde

Added a New Effects


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174215 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1287f33a
...@@ -4,6 +4,10 @@ import { SubCategoryEffects } from './subcategory'; ...@@ -4,6 +4,10 @@ import { SubCategoryEffects } from './subcategory';
import { ItemEffects } from './item'; import { ItemEffects } from './item';
import { WishlistEffects } from './wishlist'; import { WishlistEffects } from './wishlist';
import { MenuEffects } from './menu'; import { MenuEffects } from './menu';
import { ProfileEffects } from './profile-info';
import { AddressEffects } from './manage-adress';
import { ReviewsEffects } from './my-review';
import { SavedCardEffects } from './saved-card';
export { export {
CartEffects, CartEffects,
...@@ -11,7 +15,11 @@ export { ...@@ -11,7 +15,11 @@ export {
SubCategoryEffects, SubCategoryEffects,
ItemEffects, ItemEffects,
WishlistEffects, WishlistEffects,
MenuEffects MenuEffects,
ProfileEffects,
AddressEffects,
ReviewsEffects,
SavedCardEffects
}; };
export default [ export default [
...@@ -20,5 +28,9 @@ export default [ ...@@ -20,5 +28,9 @@ export default [
SubCategoryEffects, SubCategoryEffects,
ItemEffects, ItemEffects,
WishlistEffects, WishlistEffects,
MenuEffects MenuEffects,
ProfileEffects,
AddressEffects,
ReviewsEffects,
SavedCardEffects
]; ];
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {AdressAction} from '../actions';
import {UserAddressService} from '../../user-address/ecm-user-address.service';
import 'rxjs/add/operator/switchMap';
@Injectable()
export class AddressEffects {
constructor (
private update$: Actions,
private addressActions: AdressAction,
private svc: UserAddressService,
) {}
@Effect() loadAddress$ = this.update$
.ofType(AdressAction.LOAD_ADDRESS)
.switchMap(() => this.svc.fetchUserAddress())
.map(userAddresses => this.addressActions.loadAddressSuccess(userAddresses));
@Effect() addNewAddress$ = this.update$
.ofType(AdressAction.ADD_NEW_ADDRESS)
.map(action => action.payload)
.switchMap(userAddress => this.svc.addNewAddress(userAddress));
// .map(userAddress => this.addressActions.addNewAddressSuccess(userAddress));
@Effect() updateAddress$ = this.update$
.ofType(AdressAction.UPDATE_ADDRESS)
.map(action => action.payload)
.switchMap(userAddress => this.svc.updateUserAddress(userAddress));
// .map(userAddress => this.addressActions.updateAddressSuccess(userAddress));
@Effect() deleteAddress$ = this.update$
.ofType(AdressAction.DELETE_ADDRESS)
.map(action => action.payload)
.switchMap(userAddress => this.svc.deleteUserAddress(userAddress));
// .map(userAddress => this.addressActions.deleteAddressSuccess(userAddress));
}
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {ReviewAction} from '../actions';
//import {EcmCartService} from '../../ecm-view/ecm-cart/ecm-cart.service';
import 'rxjs/add/operator/switchMap';
@Injectable()
export class ReviewsEffects {
constructor (
private update$: Actions,
private reviewActions: ReviewAction,
// private svc: EcmCartService,
) {}
@Effect() loadReviews$ = this.update$
.ofType(ReviewAction.LOAD_REVIEWS)
// .switchMap(() => this.svc.fetchCartItems())
.map(userReview => this.reviewActions.loadReviewsSuccess(userReview));
@Effect() updateReviews$ = this.update$
.ofType(ReviewAction.UPDATE_REVIEWS)
.map(action => action.payload)
// .switchMap(item => this.svc.updateCart(item))
.map(userReview => this.reviewActions.updateReviewsSuccess(userReview));
@Effect() deleteReviews$ = this.update$
.ofType(ReviewAction.DELETE_REVIEWS)
.map(action => action.payload)
// .switchMap(item => this.svc.deleteCartItem(item))
.map(userReview => this.reviewActions.deleteReviewsSuccess(userReview));
}
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {ProfileActions} from '../actions';
import {ProfileInfoService} from '../../user-profile/profile-info.service';
import 'rxjs/add/operator/switchMap';
@Injectable()
export class ProfileEffects {
constructor (
private update$: Actions,
private profileActions: ProfileActions,
private svc: ProfileInfoService,
) {}
@Effect() loadUserInfo$ = this.update$
.ofType(ProfileActions.LOAD_USER_INFO)
.switchMap(() => this.svc.fetchUserInfo())
.map(user => this.profileActions.loadProfileSuccess(user));
@Effect() updateUserInfo$ = this.update$
.ofType(ProfileActions.UPDATE_USER_INFO)
.map(action => action.payload)
.switchMap(user => this.svc.updateUserInfo(user));
// .map(user => this.profileActions.updateUserInfoSuccess(user));
}
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {SavedCardAction} from '../actions';
//import {EcmCartService} from '../../ecm-view/ecm-cart/ecm-cart.service';
import 'rxjs/add/operator/switchMap';
@Injectable()
export class SavedCardEffects {
constructor (
private update$: Actions,
private savedCardActions: SavedCardAction,
// private svc: EcmCartService,
) {}
@Effect() loadCards$ = this.update$
.ofType(SavedCardAction.LOAD_SAVED_CARDS)
// .switchMap(() => this.svc.fetchCartItems())
.map(userCard => this.savedCardActions.loadSavedCardsSuccess(userCard));
@Effect() addNewCards$ = this.update$
.ofType(SavedCardAction.ADD_NEW_CARD)
.map(action => action.payload)
// .switchMap(item => this.svc.addToCart(item)
.map(userCard => this.savedCardActions.addNewCardSuccess(userCard));
@Effect() deleteCards$ = this.update$
.ofType(SavedCardAction.DELETE_CARD)
.map(action => action.payload)
// .switchMap(item => this.svc.deleteCartItem(item))
.map(userCard => this.savedCardActions.deleteCardSuccess(userCard));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment