Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Can __queryParams become public? #165

Open
ergo opened this issue Dec 7, 2016 · 4 comments
Open

Can __queryParams become public? #165

ergo opened this issue Dec 7, 2016 · 4 comments

Comments

@ergo
Copy link

ergo commented Dec 7, 2016

Hello,

I'm dispatching some events in form of:

this.fire('redirect-url', {
    path: '/admin/app-resources/edit/' + response.uuid + '/' + response.resource_type
});

Now I'm receiving them in my top level document:

    handleRedirectUrl: function (event){
        console.log('handleRedirectUrl', event);
        if (event.detail.path){
            this.set('route.path', event.detail.path);
        }
        if (event.detail.params){
            this.set('route.__queryParams', event.detail.params);
        }
    }

However double underscores don't give confidence if this API should be accessed by me at all. Can we get some confirmation if it will be safe for us to use?

@akc42
Copy link
Contributor

akc42 commented Dec 8, 2016

@ergo A safe way to change path is to do the following

     switchPath: function(path, params) {
        window.history.pushState({}, null, this.generateUri(path,params));
        window.dispatchEvent(new CustomEvent('location-changed'));
      },

This is push the new url and then dispatch the location-changed event. <iron-location> and then in turn <app-location> see that and respond - setting up the route for <app-route>. I have this function in a behaviour which gets included in many elements. It doesn't need any centralised management (<iron-location> is in effect doing that)

Note the generatURI function just encodes the params object as query parameters and appends it to path

@abdonrd
Copy link
Member

abdonrd commented Dec 8, 2016

Maybe this? #154

@ernsheong
Copy link

ernsheong commented Sep 25, 2017

Isn't it supposed to be used with app-location in the form of:

  <app-location route="{{route}}" query-params="{{queryParams}}"></app-location>
  <app-route route="{{route}}" pattern="[[rootPattern]]:page" data="{{routeData}}"></app-route>

@robrez
Copy link

robrez commented Oct 24, 2018

ping?

> $0.queryParams === $0.route.__queryParams
   true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants