ready-base
base class support jquery-like ready mechanism
Last updated 3 years ago by luckydrq .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ready-base 
SYNC missed versions from official npm registry.

ready-base

A simple mechanism that supports jquery-like ready staff. It is useful when the process of instance initialization is async. Note that if .ready is called after initialization, the callback is called immediately.

Install

npm install ready-base

Quick Start

  var util = require('util');
  var ReadyBase = require('ready-base');

  function MyClass() {
    ReadyBase.call(this);

    var self = this;
    setTimeout(function() {
      self.emit('ready');
    }, 1000);
  }
  util.inherits(MyClass, ReadyBase);

  var instance = new MyClass();

  // promise
  instance.ready()
    .then(function() {
      console.log('ready');
    });

  // or callback
  instance.ready(function() {
    console.log('ready');
  });

  // or event
  instance.on('ready', function() {
    console.log('ready');
  });

Lisence

MIT

Current Tags

  • 0.2.4                                ...           latest (3 years ago)

7 Versions

  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 12
Last Day 0
Last Week 9
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |