Home Reference Source Test
import Loader from 'seed-engine/src/utils/Loader.js'
public class | source

Loader

Helper class for waiting for async code to complete, before continuing with code. Allows multiple async loading of different types (prmoises/async-await functions) to be organized into one "Loader".

Constructor Summary

Public Constructor
public

constructor(loadCompleteCallback: function)

Loader constructor.

Member Summary

Public Members
public
public
public
public
public

Method Summary

Public Methods
public

load(promise: Promise)

Adds a Promise to the loader.

public

start()

Notifies the loader that you allow the loadCompleteCallback to be triggered once all items are loaded.

Public Constructors

public constructor(loadCompleteCallback: function) source

Loader constructor. Requires a callback function; called when all loading elements are complete.

Params:

NameTypeAttributeDescription
loadCompleteCallback function

Callback function once loading is complete.

Public Members

public loadCompleteCallback: * source

public loadCount: number source

public loadCountQueued: number source

public objectsToLoad: number source

public started: boolean source

Public Methods

public load(promise: Promise) source

Adds a Promise to the loader. Adding a promise wraps it allow the Loader to determine when loading is done. The load complete callback is not triggered until start() is called.

Params:

NameTypeAttributeDescription
promise Promise

A pending promise.

public start() source

Notifies the loader that you allow the loadCompleteCallback to be triggered once all items are loaded. Items will be loading before start is called, the results are just queued until start is called.