question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataPersistence navigation run method is not triggered when using RouterState.Minimal

See original GitHub issue

Expected Behavior

I am not sure about what the expected behaviour should be regarding the effect, since I understand that the navigation logic requires access to the routed component in order to match it and fire the run trigger. However, some documentation warning us that this combination is not compatible or some kind of runtime checks (if that were possible) instead of silently ignoring the effect would be nice.

Current Behavior

When trying to use a navigation effect, the run block only gets fired if the RouterState serialization strategy is not Minimal. The reason for this is that the findSnapshot function requires access to the routed Component, which is not included when using the RouterState.Minimal serializer. As far as I understand, this serializer is useful for having fully serializable actions, which the default serializer doesn’t provide.

Context

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.1.0-beta.2
Node: 10.15.0
OS: win32 x64
Angular: 8.1.0-next.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.801.0-beta.2
@angular-devkit/build-angular     0.801.0-beta.2
@angular-devkit/build-optimizer   0.801.0-beta.2
@angular-devkit/build-webpack     0.801.0-beta.2
@angular-devkit/core              8.1.0-beta.2
@angular-devkit/schematics        8.1.0-beta.2
@angular/cdk                      8.0.1
@angular/cli                      8.1.0-beta.2
@angular/flex-layout              8.0.0-beta.26
@angular/http                     8.0.0-beta.10+1.sha-a28b3e3
@angular/material                 8.0.1
@ngtools/webpack                  8.1.0-beta.2
@schematics/angular               8.0.1
@schematics/update                0.801.0-beta.2
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.34.0

Ngrx related packages version:

"@ngrx/store": "^8.0.1",
"@ngrx/effects": "^8.0.1",
"@ngrx/entity": "^8.0.1",
"@ngrx/router-store": "^8.0.1",

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
brandonrobertscommented, May 21, 2020

We have fixed this upstream in NgRx so that you can use the serialization/immutability checks with the full router state, so these workarounds aren’t needed. See https://github.com/ngrx/platform/pull/2491 and https://github.com/ngrx/platform/pull/2351 for context

0reactions
ramariveracommented, Jun 6, 2020

Alternatively, would you accept PR that makes DataPersistence navigation method able to work based only on the routed component name, alongiside a custom router state serializer for this purpose?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dataPersistence.navigation not executing when navigating to url
An immediate workaround that's working for me is adding an effect that watches for ngrx's navigation. export const onNav = createAction('@ngrx/ ...
Read more >
I ve finally got time to… - @Nrwl/Community
... has anybody else been able to do this? [nrwl/nx] #1538 DataPersistence navigation run method is not triggered when using RouterState.Minimal.
Read more >
Using Data Persistence operators - Nx
The fetch operator provides consistency when fetching data. If there are multiple requests scheduled for the same action, it will only run the...
Read more >
Angular - Routes and Navigation @ https://jojozhuang.github.io
Imperative navigation is not generating links; it's simply telling the router to go somewhere, performing navigation in your code. The two methods are...
Read more >
ENTERPRISE ANGULAR MONOREPO PATTERNS - OpenProject ...
This creates a new Nx Workspace using a sandboxed environment and running the ... DataPersistence navigation method checks if an activated router state...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found