@w-vision/load-yumpu-api

1.0.0 • Public • Published

Load Yumpu API

npm Version Build Status Build Status

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

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

Usage

Edit Demo Load Yumpu API

import loadYumpuApi from '@w-vision/load-yumpu-api';

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

N.B. Just like the Yumpi API itself, this module is client-side only.

Motivation

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 Rollup or Webpack.

API

import loadYumpuApi from '@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

Package Sidebar

Install

npm i @w-vision/load-yumpu-api

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

5.64 kB

Total Files

4

Last publish

Collaborators

  • w-vision-developer