A thin, Promise-returning helper for loading the Yumpu JavaScript API.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs/images
.gitignore
.travis.yml
LICENSE.md
README.md
index.js
package.json
test.js
yarn.lock

README.md

Load Yumpu API

npm Version Build Status

A thin, Promise-returning helper for loading the Yumpu JavaScript API.

  • The Promise’s fulfilled callback is passed the Yumpu object
  • 224 bytes gzipped

Usage

Edit k3ko7w43zv

const loadYumpuApi = require('@w-vision/load-yumpu-api');

loadYumpuApi().then(function (Yumpu) {
  const yumpu = new Yumpu();
  yumpu.create_player('#magazineContainer', '17403069');
}).catch(function (error) {
  console.error(error);
});

Why

Without this module, you would need to add a script tag to your page. For example:

<script src="https://players.yumpu.com/hub.js"></script>
<script type="text/javascript">
  // `window.Yumpu` available here
</script>

This module abstracts this ceremony away, and fits better with modern bundlers like Browserify or Webpack.

API

const loadYumpuApi = require('@w-vision/load-yumpu-api');

loadYumpuApi()

Returns a Promise.

  • Fulfilled if loading was successful. The fulfilled callback is passed the Yumpu object. If loadYumpuApi is called multiple times on a page, the fulfilled callback will be passed the previously-loaded Yumpu object.
  • Rejected if we weren’t able to load the Yumpu API.

See Usage.

Installation

Install via yarn:

$ yarn add @w-vision/load-yumpu-api

Or npm:

$ npm install --save @w-vision/load-yumpu-api

License

MIT