• [Anuglar & NgRx] StoreRouterConnectingModule


    Always treat Router as the source of truth

    When we use Ngrx, we can see that we will use a "StoreRouterConnectingModule" from the example app.

    What it does, is that, it connects router state to store, 

    It will set up the router in such a way that right after the URL gets parsed and the future router state gets created, the router will dispatch a RouterAction

    Check the post.

    Code example:

    class TalksEffects {
      @Effect() navigateToTalks = this.actions.ofType(ROUTER_NAVIGATION).
        map(firstSegment).
        filter(s => s.routeConfig.path === "talks").
        switchMap((r: ActivatedRouteSnapshot) => {
          const filters = createFilters(r.params);
          return this.backend.findTalks(filters)
    .map(resp => ({type: 'TALKS_UPDATED', payload: {...resp, filters}})); }).catch(e => { console.log('Network error', e); return of(); }); }

    We can listen for "ROUTER_NAVATION" event, filter though the path, get the activated route snapshot, then snyc Router URL with BE.

  • 相关阅读:
    Jenkins
    python爬虫
    git分布式版本控制
    CKA考试认证总结
    gitlab-ci 工具链
    gitlab-ci 模板库实践
    gitlab-cicd
    gitlab配置文件gitlab.rb详解
    局部变量表中的slot简述
    JVM系统线程类型
  • 原文地址:https://www.cnblogs.com/Answer1215/p/7757683.html
Copyright © 2020-2023  润新知