• Stars
    star
    344
  • Rank 123,066 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ES6-compatible and Promises/A+ implementation for Node.js and browsers

Vow NPM Version Build Status NPM Downloads

Vow is a Promises/A+ implementation. It also supports ES6 Promises specification.

Full API reference can be found at http://dfilatov.github.io/vow/.

Getting Started

In Node.js

You can install using Node Package Manager (npm):

npm install vow

In Browsers

<script type="text/javascript" src="vow.min.js"></script>

It also supports RequireJS module format and YM module format.

Vow has been tested in IE6+, Mozilla Firefox 3+, Chrome 5+, Safari 5+, Opera 10+.

Usage

Creating a promise

There are two possible ways to create a promise.

1. Using a deferred

function doSomethingAsync() {
    var deferred = vow.defer();
    
    // now you can resolve, reject, notify corresponging promise within `deferred`
    // e.g. `defer.resolve('ok');`
        
    return deferred.promise(); // and return corresponding promise to subscribe to reactions
}

doSomethingAsync().then(
    function() {}, // onFulfilled reaction
    function() {}, // onRejected reaction
    function() {}  // onNotified reaction
    );

The difference between deferred and promise is that deferred contains methods to resolve, reject and notify corresponding promise, but the promise by itself allows only to subscribe on these actions.

2. ES6-compatible way

function doSomethingAsync() {
    return new vow.Promise(function(resolve, reject, notify) {
        // now you can resolve, reject, notify the promise
    });
}

doSomethingAsync().then(
    function() {}, // onFulfilled reaction
    function() {}, // onRejected reaction
    function() {}  // onNotified reaction
    );

Extensions and related projects

  • vow-fs β€” vow-based file I/O for Node.js
  • vow-node β€” extension for vow to work with nodejs-style callbacks
  • vow-queue β€” vow-based task queue with weights and priorities
  • vow-asker β€” wraps asker API in the vow promises implementation

NOTE. Documentation for old versions of the library can be found at https://github.com/dfilatov/vow/blob/0.3.x/README.md.

More Repositories

1

jspath

DSL that enables you to navigate and find data within your JSON documents
JavaScript
552
star
2

vidom

Library to build UI based on virtual DOM
JavaScript
415
star
3

bem-react

BEM-flavoured React
JavaScript
132
star
4

inherit

Inheritance module for Node.js and browsers
JavaScript
71
star
5

lrt

Scheduler for long-running tasks inside browsers and Node.JS
TypeScript
66
star
6

vow-fs

Vow-based file I/O for Node.js
JavaScript
28
star
7

jquery-plugins

collection of jQuery plugins
JavaScript
27
star
8

vow-queue

Vow-based task queue
JavaScript
10
star
9

twitter-trends

Example of bem app
JavaScript
9
star
10

vow-node

Extension for Vow to work with nodejs-style callbacks
JavaScript
9
star
11

jaggi

JavaScript
9
star
12

jz

JavaScript
8
star
13

vidom-redux

Redux bindings for Vidom
JavaScript
7
star
14

BEM-inspector

Chrome extension for browsing BEM
JavaScript
6
star
15

bem-components-react

CSS
6
star
16

vidom-ui

A set of basic visual components are built with Vidom
JavaScript
6
star
17

babel-plugin-vidom-jsx

Plugin for babel to enable JSX for Vidom
JavaScript
6
star
18

rou

Url-based router for Node.js and browsers.
JavaScript
4
star
19

vidom-inspector

Inspector for vidom
JavaScript
3
star
20

flex-layout

BEM-block for custom layout
JavaScript
3
star
21

touch-mapper

Touch mapper plugin for jQuery
JavaScript
2
star
22

redut

Redut is a minimal library to build type-safe redux applications with TypeScript and without a lot of boilerplate code.
TypeScript
2
star
23

jquery-wname

Window.name-based transport for jQuery.Ajax with crossdomain file's uploading support
2
star
24

dotfiles

my dotfiles
1
star
25

vidom-todomvc

TodoMVC via Vidom
JavaScript
1
star
26

jemplate

simple template plugin for jquery
JavaScript
1
star
27

vidom-animation-group

Low-level API for "appearance", "entering" and "leaving" animation inside Vidom.
JavaScript
1
star
28

vidom-css-animation-group

API for "appearance", "entering" and "leaving" animation via CSS transitions and animations inside Vidom
JavaScript
1
star