Skip to content

Instantly share code, notes, and snippets.

@spra85
Created April 17, 2017 21:00
Show Gist options
  • Save spra85/a02b0499d9043b8a4bd6f742037722b9 to your computer and use it in GitHub Desktop.
Save spra85/a02b0499d9043b8a4bd6f742037722b9 to your computer and use it in GitHub Desktop.

Add lazy attribute to campaign-display

<campaign-display
                  class="campaign-display-drawerered"
                  preamble-text="{{ special_coverage.name }} by"
                  src="{% content_tunic_campaign_url special_coverage.tunic_campaign_id %}"
                  placement="recirc"
                  name-only
                  no-link
                  no-pixel lazy>
              </campaign-display>

The lazy flag would make sure that the fetchCampaign method doesn't execute when the node is attached to the DOM.

We would add attributeChangedCallback to make this call, e.g.:

attributeChangedCallback (name, previousValue, value) {
 if (!lazy && this.props.src) { // pseudo code
    this.store.actions.fetchCampaign(this.props.src);
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment