TNG / ngqp

Declaratively synchronize form controls with the URL
https://tng.github.io/ngqp
MIT License
81 stars 8 forks source link

Expose a replayed value$ observable #177

Open Airblader opened 3 years ago

Airblader commented 3 years ago

What's your idea? QueryParam and QueryParamGroup currently expose a valueChanges observable, akin to Angular Forms, which is backed by a Subject<>. This can create a problem as the first value may be "missed", see #72 and #176. While there is a relatively easy solution to this, it still creates unnecessary boilerplate and can be confusing.

Therefore, we should expose a value$ observable on both which is backed by a ReplaySubject<>(1). This makes it easier for users to connect ngqp to their logic.

Airblader commented 3 years ago

As a side note, in the documentation we should prioritize & encourage the use of value$ and discourage that of valueChanges.

w5l commented 2 years ago

Moving users away from valueChanges implicitly means moving the project away from following the Angular Forms style. Using startsWith(...) fixes the issue and when needed in multiple locations, it can be moved into a wrapper class.