Skip to content

w-vision/load-yumpu-api

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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