Package Exports
- require-sdk
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (require-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
require-sdk
JavaScript library for making sure given SDK is loaded and executed. Designed for popular APIs like Youtube, Rdio, Soundcloud etc.
See tests.js for examples.
Install
$ npm install require-sdkUsage
requireSDK = require('require-sdk')
requireFoo = requireSDK('http://foo.com/api.js')
requireFoo(function () {
// foo.com/api.js loaded
Foo('do something')
})
requireFoo(function () {
// you can add multiple callbacks.
// it lets you easily wrap all your SDK dependent code
// and makes your code look meaningful
})Check if it's already loaded:
var requireFoo = requireSDK('https://www.youtube.com/iframe_api', 'YT') // Doesn't attempt to load if window.YT is definedManually trigger the load event if custom conditions required:
var requireFoo = requireSDK('https://youtube.com/iframe_api', 'YT')
window.onYouTubeIframeAPIReady = requireFoo.trigger() // load event delays until onYouTubeIframeAPIReady is called