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

Attached Method Calling on iron pages? #47

Closed
nigeltiany opened this issue Sep 12, 2016 · 3 comments
Closed

Attached Method Calling on iron pages? #47

nigeltiany opened this issue Sep 12, 2016 · 3 comments

Comments

@nigeltiany
Copy link

nigeltiany commented Sep 12, 2016

What would be a better way to recalculate bindings when a page moves from being unselected to selected? Is an iron-page supposed to be attached when selected and dettached otherwise? That way a polymer component that is an iron page can have the attached property as a function that can be used to recalculate data bindings?

Here is my code

...
    <div>[[active]]</div>
</template
<script>
        Polymer({
            is: 'control-panel',
            properties: {
                active: {
                    type: String
                }
            },
            attached: function () {
                console.log('attached');
              this.active = this.activeAccount();
            },
            dettached: function () {
                console.log('dettached');
            },
           activeAccount: function(){
                //gets value by key from iron local storage
           }
           });
</script>
<iron-pages selected="[[view]]" attr-for-selected="name" role="main">
        <control-panel id="panel" name="panel"></control-panel>
        <choose-account name="accountSelect"></choose-account>
</iron-pages>
@43081j
Copy link

43081j commented Sep 28, 2016

Do you mean something like the selectedAttribute?

<iron-pages selected-attribute="active" ...> will mean your boolean property, active, is set true/false when the page is active or not. Then in your observer of said property, update internal state if active === true.

@nigeltiany
Copy link
Author

What i meant was life cycle callbacks. Methods that can called when an iron page is currently active, moves from being active or being viewed to hidden or inactive and any other callbacks necessary.

@43081j
Copy link

43081j commented Sep 29, 2016

Isn't this exactly what I just said?

In the code snippet I posted above, you would have an observer on active. You say you want some kind of callback when the page moves from active to inactive, this is it. An observer on the selected attribute, which in my example is active.

attached/detached of course won't fire, it has already been attached. iron-pages will simply hide it. So how do you know it has hidden or unhidden? Again, an observer on the attribute specified in selectedAttribute.

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

2 participants