0.0.1 • Published 7 years ago

install-prompt v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

install-prompt npm version Build Status codecov

This is a small library for handling install Banner for Progreww Web Application(PWA).

Dependency

No dependency

Install

yarn add install-prompt

Usage

import InstallPrompt from 'install-prompt';
// initial installPrompt
const installPrompt = new InstallPrompt();

// add 1 count when user do some interactive
installPrompt.addCount();

// check if prompt should popup
installPrompt.checkPrompt();

Real example (React)

  import InstallPrompt from 'install-prompt';
  ...
  componentDidMount() {
    this.installPrompt = new InstallPrompt();
    this.installPrompt.addCount();
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.cid !== this.props.cid) {
      this.installPrompt.addCount().checkPrompt();
    }
  }

Options

  • promptKey: (string) default is 'installPrompt'

  • minimumPrompt: (number) default is 2

e.g,

const installPrompt = new InstallPrompt({
  promptKey: 'custom-localstorage-key',
  minumumPrompt: 5
});

Development

yarn dev

Test

yarn test