brangerbriz / liBB.js

A JavaScript library/framework for creating interactive && generative apps + installations in/out of the browser
http://libb.brangerbriz.com/
GNU General Public License v3.0
1 stars 2 forks source link

BBx Suggestion #32

Closed brannondorsey closed 7 years ago

brannondorsey commented 8 years ago

I put a bit more thought into the way that we are thinking about writing modules that depend on other libraries to be pre-loaded in the global context of the page (LeapMotion, THREE, etc...). I had the idea that maybe we could use the BBx namespace instead of the BB namespace for anything that has a dependency. These modules could still live in src and only throw runtime errors if needed libraries dependencies aren't found but it would be a good way to let the programmer know they need to include something w/out having to look it up in the documentation. BBx objects could also then have a dependencies property that is an array of all of the names/paths of those dependency sources as well as a loadDependencies(...) function to be used as a utility to easily load them without having to include them as a script tag in index.html, etc...

BB.Vector2 
// vs 
BBx.LeapMotion // where 
BBx.LeapMotion.dependencies = ['leap_library_name.js'];
BBx.LeapMotion.loadDependencies(function(){
    // callback
});

All BBx objects could then derive from BB.BaseBBxObject() that has those helpful methods/properties.

nbriz commented 8 years ago

yea, the idea of a BB.BaseBBxObject() w/ .dependencies + .loadDependencies ( even the Error that checks to see if the dependency is loaded && if not maybe tries to load it assuming it's in root or js && if not throws the error? ) >> that'll help keep things consistent.

but why BBx? just for clear API's sake? i'm not opposed to it...

nbriz commented 7 years ago

this is being handled via the dependency check within each module. see the module template file in the documentation for a break down on this