Last active
March 20, 2019 17:13
-
-
Save kylebuch8/41cddb6eae056094486191bf03fcf6a9 to your computer and use it in GitHub Desktop.
Revisions
-
kylebuch8 revised this gist
Mar 20, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,14 +12,13 @@ class MySimplePfelement extends PFElement { super(MySimplePfelement, { delayRender: true }); this.data = {}; this._fetchData(); } _fetchData() { fetch("someapi.json") .then(res => res.json()) .then(() => this._handleFetch); } _handleFetch(data) { -
kylebuch8 created this gist
Mar 18, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ // the location of pfelement.js may be different if you're not building an element in the // PatternFly elements repository import PFElement from "../pfelement/pfelement.js"; class MySimplePfelement extends PFElement { constructor() { // make sure we call super() first with the class we're using // as the first argument // the second argument in super() is an object with delayRender: true // because we don't want the HTML template to be rendered immediately super(MySimplePfelement, { delayRender: true }); this.data = {}; this._handleFetch = this._handleFetch.bind(this); this._fetchData(); } _fetchData() { fetch("someapi.json") .then(res => res.json()) .then(this._handleFetch); } _handleFetch(data) { this.data = data; // be sure to call this when you are ready for the HTML template // to be displayed in the shadow root // render() is a method on the PFElement class this.render(); } }