-
Notifications
You must be signed in to change notification settings - Fork 4
Loading source bundles
Ioannis Charalampidis edited this page Jun 7, 2016
·
3 revisions
You need the following node modules:
npm install --save jbb
Even though it's not recommended, since it's more heavyweight, you can load a .jbbsrc bundle in the browser or in your node.js project or the browser in the same way you would load a binary bundle.
This time you should use the require("jbb/loader") or the JBB.SourceLoader instead of the require("jbb/decoder") and JBB.BinaryLoader:
// Get a reference to the JBB loader
var JBBLoader = require("jbb/loader");
// Add one or more profile loaders needed by the bundle
loader.addProfileLoader( require("jbb-profile-name/profile-loader") );
// Add one or more source bundles to load
loader.add("bundle_name.jbbsrc");
// Load all of them and callback when ready
loader.load(function(err, database) {
// Handle errors
if (err) {
alert("Loading error: "+err);
return;
}
// Handle your data here
var my_object = database["bundle_name/resource_name"];
});