AsyncLoader.js 348 B

1234567891011121314151617
  1. import * as RE from 'rogue-engine';
  2. export default class AsyncLoader {
  3. loadStaticText(filepath) {
  4. return new Promise((success, failure) => {
  5. fetch(RE.getStaticPath(filepath)).then(result => {
  6. result.text().then(text => {
  7. success(text)
  8. }, error => {
  9. failure(error)
  10. })
  11. }, error => {
  12. failure(error)
  13. })
  14. })
  15. }
  16. }