Created
January 31, 2018 20:51
-
-
Save andeplane/cd9b67048a1648dba0b06e9966b6c60f to your computer and use it in GitHub Desktop.
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 characters
import test from './test.txt' | |
class A { | |
constructor() { } | |
async loadFile(filename) { | |
let data = await (await fetch(filename)) | |
return data | |
} | |
} | |
class B extends A { | |
constructor() { | |
super() | |
this.contents = '' | |
} | |
async loadFile(filename) { | |
let data = await super.loadFile(filename) | |
data.text().then( text => { | |
console.log('Text: ', text) | |
this.parse(text) | |
}).catch( error => { | |
console.log('Error: ', error) | |
}) | |
} | |
parse (data) { | |
this.contents = data | |
console.log('Parsing data: ', data) | |
} | |
} | |
let b = new B() | |
b.loadFile(test).then( () => { | |
console.log('Got data now: ', b.contents) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment