Cache

cruft/net/Cache.js
This class defines a Cache.

Importing#

import Cache from "cruft/net/Cache";

Methods#

register( name, Loader )#

Register Cache loader to the given name.

import ObjLoader from "cruft/net/loaders/ObjLoader";
cache.register("obj", new ObjLoader());
cache.get("obj!assets/models/CruftModel.obj").then((asset) => {
    //asset is the parsed obj model
});

get( path )#

Path to the asset to load. Optionaly prefixed with pluginname! to specify which loader to use.

cache.get("json!assets/data/data.json").then((data) => {
    console.log(data.pasword)//data is an obect. 
});

load( ...paths )#

load all of the specified paths.

cache.load("json!assets/data/data.json", "json!assets/data/data2.json").then((paths) => {
    console.log(paths["json!assets/data.txt"]); // contents of data.json
})