日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ngrx心得体会总结

發(fā)布時間:2024/4/17 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ngrx心得体会总结 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

ngrx心得體會總結

一個典型的場景:添加店鋪商品,其中店鋪有多個,每個店鋪有不同的商品分類,商品分類可以多級!

@Injectable() export class AppEffects {// 添加店鋪商品@Effect()StartAddShopGoods$ = this.ofType(ActionTypes.StartAddShopGoods).pipe(takeUntil(this.ofType(ActionTypes.Error).pipe(tap(res => console.log('發(fā)生了點錯誤')))),switchMap(res => {// 加載店鋪this.store.dispatch(new SearchShop());this.router.navigate(['/select-shop'], { replaceUrl: false, skipLocationChange: true });// 添加選擇店鋪return this.ofType(ActionTypes.SelectShop).pipe(switchMap(res => {// 加載店鋪商品分類this.store.dispatch(new SearchShopGoodsCategory());this.router.navigate(['/select-shop-goods-category'], { replaceUrl: false, skipLocationChange: true });// 選擇店鋪商品分類return this.ofType(ActionTypes.SelectShopGoodsCateogry).pipe(tap(res => {// 商品信息this.router.navigate(['/shop-goods-edit'], { replaceUrl: false, skipLocationChange: true });}),switchMap(res => {// 點擊提交按鈕return this.ofType(ActionTypes.AddShopGoods).pipe(switchMap(res => this.util.wpost('iwe7ShopGoods', 'Upsert', {}).pipe(map(res => {// 添加成功this.router.navigate(['/user-center'], { replaceUrl: false, skipLocationChange: true });return new AddSuccessShopGoods();}))));}));}));}));// 公共加載@Effect()SearchShop$ = this.ofType(ActionTypes.SearchShop).pipe(switchMap(res => {return this.util.wpost('iwe7Shop', 'Loads', {}).pipe(pluck('data'),pluck('list'));}),map(res => {return new SearchSuccessShop(res);}));@Effect()SearchShopGoodsCategory$ = this.ofType(ActionTypes.SearchShopGoodsCategory).pipe(switchMap(res => {return this.util.wpost('iwe7ShopGoodsCategory', 'Loads', {}).pipe(pluck('data'),pluck('list'));}),map(res => {return new SearchSuccessShopGoodsCategory(res);}));constructor(private actions$: Actions,private store: Store<any>,private util: Iwe7Util2Service,private router: Router) { }ofType<T extends Action>(name: string): Actions<T> {return this.actions$.ofType<T>(name);} }復制代碼

總結: actions 定義操作 effects 串聯(lián)actions,完成業(yè)務邏輯 reducers 操作Store model 定義結構

總結

以上是生活随笔為你收集整理的ngrx心得体会总结的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。