You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a SPA that keeps some state in the browser hash, e.g. http://foo.com/page-uri?searchparam=value#focusedElement=bar.
I just hit a case of wanting to visit a page with some state pre-specified in the URL, but found that there's no way to do this using the normal browser.to(page) pattern. The fallback is to construct the page url manually and then use browser.go(theUrl); browser.at(page), but this is a bit ugly.
This could take the form of duplicated to() / via() methods with an extra param on the end for the hash. One annoyance is that it would read weirdly, since the params map is currently the last one:
Alternatively, the new form could force API consumers to just put their params in a map in the natural order, which would make readability a bit better
Thanks for raising this. I don't remember all the signatures of to() from
the top of my head so I'm not sure what's possible but I'd rather we went
for being explicit by introducing a signature taking UrlHash which would
have a static factory method of() taking a String than some magic via map
keys.
While this is making its way into the core you can probably implement
something nicer than what you have at the moment by using convertToPath()
on your pages (
http://www.gebish.org/manual/current/#advanced-page-navigation).
On Fri, 23 Dec 2016 at 06:22, Tom Dunstan ***@***.***> wrote:
We have a SPA that keeps some state in the browser hash, e.g.
http://foo.com/page-uri?searchparam=value#focusedElement=bar.
I just hit a case of wanting to visit a page with some state pre-specified
in the URL, but found that there's no way to do this using the normal
browser.to(page) pattern. The fallback is to construct the page url
manually and then use browser.go(theUrl); browser.at(page), but this is a
bit ugly.
This could take the form of duplicated to() / via() methods with an extra
param on the end for the hash. One annoyance is that it would read weirdly,
since the params map is currently the last one:
browser.to(myPageClass, [subpath], 'hashfoo=bar', param: 'baz')
Alternatively, the new form could force API consumers to just put their
params in a map in the natural order, which would make readability a bit
better
browser.to(myPageClass, [subpath], [param: 'baz'], 'hashfoo=bar')
A different approach could be to use a magic key and pass the hash as a
param:
browser.to(myPageClass, [subpath], param: 'baz', (Browser.HASH):
'hashfoo=bar')
Another thing to consider would be allowing the hash to be specified as a
map, as this is quite common for SPAs:
browser.to(myPageClass, [subpath], [param: 'baz'], [hashfoo: 'bar'])
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#463>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMii5KmkI0l2c7AWKKV7YmVZWogvCQqks5rK2iXgaJpZM4LUmbB>
.
We have a SPA that keeps some state in the browser hash, e.g.
http://foo.com/page-uri?searchparam=value#focusedElement=bar
.I just hit a case of wanting to visit a page with some state pre-specified in the URL, but found that there's no way to do this using the normal
browser.to(page)
pattern. The fallback is to construct the page url manually and then usebrowser.go(theUrl); browser.at(page)
, but this is a bit ugly.This could take the form of duplicated
to() / via()
methods with an extra param on the end for the hash. One annoyance is that it would read weirdly, since the params map is currently the last one:browser.to(myPageClass, [subpath], 'hashfoo=bar', param: 'baz')
Alternatively, the new form could force API consumers to just put their params in a map in the natural order, which would make readability a bit better
browser.to(myPageClass, [subpath], [param: 'baz'], 'hashfoo=bar')
A different approach could be to use a magic key and pass the hash as a param:
browser.to(myPageClass, [subpath], param: 'baz', (Browser.HASH): 'hashfoo=bar')
Another thing to consider would be allowing the hash to be specified as a map, as this is quite common for SPAs:
browser.to(myPageClass, [subpath], [param: 'baz'], [hashfoo: 'bar'])
The text was updated successfully, but these errors were encountered: