TNG / ngqp

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

Synchronize router based on manual trigger #165

Open dev054 opened 4 years ago

dev054 commented 4 years ago

Hello, thanks for this great library, it's awesome! I'm about to use it in a new project, however my requirement is to synchronize filters in a table based on submit button. Is there any way to accomplish this? I thought something like { updateOn: 'submit' } from FormBuilder, but I couldn't find anything similar on documentation. Thanks in advance.

Airblader commented 4 years ago

Thanks for opening this issue. I'm currently recovering from an illness and on vacation, so unfortunately I can't look into this in detail quite yet, but I will definitely do so once I am back!

In general this is something I've had in mind but so far explicitly excluded since most of the complexity of ngqp wouldn't be needed for this — setting and reading parameters once is pretty easy, problems like debounce and syncing don't really occur. That said I can see why it would be nice if ngqp supported that for convenience reasons. Also ngqp just evolved since this decision was made and there would be some benefits to supporting this now for sure.

I am, however, a bit unsure of the "submit trigger" idea since ngqp currently doesn't need to deal with surrounding forms or form submission at all. An API to disable automatic syncing and trigger it explicitly, however, might be fairly easy to introduce.

A possible workaround at the moment might be to provide a custom router adapter that proxies everything to only happen on a defined trigger (I'll get more info this when I'm back).

Airblader commented 3 years ago

Sorry for the late reply – my illness took longer than anticipated and this fell off my radar. I was just reminded of this in #180, and here's a prototype of the workaround I mentioned: https://stackblitz.com/edit/angular-ivy-hgjj6l?