ergo / polymer-ui-router

UI-router wrapper for Web Components
Apache License 2.0
22 stars 6 forks source link

Pass bound values downwards, through uirouter-uiview or otherwise #6

Closed vidhill closed 6 years ago

vidhill commented 6 years ago

I have some data that I was passing down to child elements using binding,

I don't think I can do that with uirouter-uiview, I thought I might be able to do it using a resolve function but the context for this is the global element..

<uirouter-uiview current-user-name="[[currentUserName]]" notification-decision="[[notificationDecision]]" >
</uirouter-uiview>

I've read the source and I don't know if this is possible,

ergo commented 6 years ago

It already should be supported, resolved data are getting passed to ui-view. https://github.com/ergo/polymer-ui-router/blob/master/uirouter-uiview.html#L140

vidhill commented 6 years ago

Which method should work? Using the binding syntax above?

I can get the resolver to pass data alright, but I can't work out hot to pass a value from a parent scope -As I cannot seem to get a reference to the element from the Resolver

ergo commented 6 years ago

@vidhill I think you might be right here, I never used this functionality in either angular or polymer. This would require probably some changes in uirouter-uiview, is there any other way to pass the binding downwards in the meantime?

vidhill commented 6 years ago

I don't know, I'm kind of scratching my head.. I could introduce polymer-redux to my project, but I don't want to do too much refactoring in one PR

I might try giving modifying uirouter-uiview a go,

from what I read Polymer doesn't provide any utilities for adding bindings to manually created elements

ergo commented 6 years ago

@vidhill pinged you on slack

ergo commented 6 years ago

Closing, feel free to reopen if you need help.

ergo commented 6 years ago

@vidhill I'm repoening this, currently looking for a solution which allows discovering and observing properties unknown upfront.

https://github.com/Polymer/polymer/issues/4636 - this issue should be helpful.

ergo commented 6 years ago

Next release of ui-router will allow for something like this:

<uirouter-uiview component="default-comp" counter="[[counter]]" clock="[[clock]]"
       pass-downwards="[[passDownwards]]"></uirouter-uiview>

where passDownwads is an array of ['counter', 'clock'] and this will hint the view to pass the props to stomped element and create change observers to get things in sync.