0.0.3 • Published 7 years ago

bg-timer-helper v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 years ago

bg-timer-helper

Mini-tool to leave JavaScript executions awake after window unfocused (mobile device screen turned off, browser tab switched to another)

Content

  1. Description
  2. Get Started
    1. React
  3. API

Description

Here described this problems for timeouts, and in the same article described the solution for it:

Firefox 50 no longer throttles background tabs if a Web Audio API AudioContext is actively playing sound.

This small package initalize AudioContext on the page for modern browsers and using this tricky way all timers no throttling more. As easy as possible.

WARNING! Be careful and use this tool only if you really haven't any another ways, browser developers don't just put a lot of effort into optimizing and firstly try to experiment with:

Get Started

Install

npm install --save bg-timer-helper

or with yarn

yarn add bg-timer-helper

React

import BgTimerHelper from 'bg-timer-helper';

export default class App extends React.Component {
	constructor() {
    	super();
        this.bgTimerHelper = new BgTimerHelper();
    }
    
    componentDidMount() {
    	this.bgTimerHelper.enable();
    }
    
    componentWillUnmount() {
    	this.bgTimerHelper.disable();
    }
}

API

Methods

enable(); // start playing audio
disable(); // stop playing audio
0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago