Skip to content

Commit

Permalink
Update index.js for server rendering (isomorphic) (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
luntegg authored and leoasis committed May 5, 2017
1 parent 017e175 commit 782983b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import React from 'react';
import T from 'prop-types';
import { soundManager } from 'soundmanager2';

const pendingCalls = [];
let initialized = false;

let soundManager;
if (typeof window !== 'undefined') {
soundManager = require('soundmanager2').soundManager;

soundManager.onready(() => {
pendingCalls.slice().forEach(cb => cb());
});
}

function createSound(options, cb) {
if (soundManager.ok()) {
cb(soundManager.createSound(options));
Expand All @@ -27,10 +35,6 @@ function createSound(options, cb) {
}
}

soundManager.onready(() => {
pendingCalls.slice().forEach(cb => cb());
});

function noop() {}

const playStatuses = {
Expand Down

0 comments on commit 782983b

Please sign in to comment.