Comments (3)
Thanks for reporting this and, importantly, providing a StackBlitz! I will take a closer look and a more detailed reply later on, but if you need a way to make this work quickly, this is it:
this.paramGroupValues$ = defer(() => this.paramGroup.valueChanges.pipe(
startWith(this.paramGroup.value),
takeUntil(this.ngUnsubscribe)
));
from ngqp.
I can confirm this work-around resolves the issue!
from ngqp.
So to explain a bit further, in case it isn't clear now anyway, the difference is essentially the timing of when paramGroup.value
is evaluated. In
this.paramGroupValues$ = this.paramGroup.valueChanges.pipe(
startWith(this.paramGroup.value),
takeUntil(this.ngUnsubscribe)
);
this happens when the observable is created, not when it is subscribed. At this point ngqp has had no time to synchronize the value from the URL, of course, and thus the value is null
. Wrapping this into defer
we can make this evaluation "lazy" such that it occurs when the observable is subscribed, which is what we want: upon subscription we track changes, but start once initially with the current value. This is essentially the same as if valueChanges
was a ReplaySubject(1)
instead of a Subject
.
The fact that I posted this wrong in #72 was just an oversight, thanks for correcting it there. :-) I'll also update my comment there afterwards.
All that being said, this does still behave as intended, and I still think changing the semantic of valueChanges
isn't ideal and would rather lean towards the idea of adding a value$
observable which is replayed. I've opened #177 for that (and will in turn close this issue).
from ngqp.
Related Issues (20)
- Partition URL parameters HOT 6
- Programmatically set value of parameters inside a partition
- emptyOn + multi leads to incorrect behavior HOT 1
- Provide the entire array to (de-)serializers for multi params
- Combination of `multi` and normal parameter breaks `valueChanges` HOT 4
- Switch multi property HOT 6
- Need Ivy support HOT 5
- valueChanges Observable from one param is leaking Events from other params of the same group. HOT 6
- Synchronize router based on manual trigger HOT 2
- Programmatically delete/remove/reset queryForms and queryParams HOT 7
- How to have custom values in select dropdowns? HOT 9
- Expose a replayed value$ observable HOT 2
- Sync URL with nested QueryParamGroup HOT 4
- Update version support on website
- Update to support Angular 13 HOT 2
- 'QueryParamModule' does not appear to be an NgModule class HOT 4
- Proper support of angular 14+ (Not working in angular 16 due to absent ngcc) HOT 7
- Types of property 'serialize' are incompatible HOT 2
- Angular 16 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngqp.