Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-es6-promise

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-es6-promise

A plugin for Backbone.js that overrides default promises with modern ES6 promises

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Backbone ES6 promise

A plugin for Backbone.js that overrides default promises with modern ES6 promises.

Build Status

Backbone ES6 promise is the simple plugin that overrides old, not trendy jQuery promises with new, awesome ES6 promises. With this tool all your request methods of models and collections will return ES6 promises.

How to install:

npm install backbone-es6-promise --save

Browser:

<script>...</script>
<!-- add polyfill if you want to support old browsers -->
<script src='promise-polyfill/promise.js'></script>
<script src='backbone-es6-promise.js' type='text/javascript'></script>

Common JS:

require('backbone-es6-promise');

How to use:

Just start to write your code with ES6 promise syntax.

const Model = Backbone.Model.extend({ urlRoot: 'url' });
const model = new Model({ id: 1, someAttribute: 'some attribute' });

model.fetch().then(data => {
  console.log(data);
}).catch(errorObject => {
  console.log(errorObject);
});

Also you are able to write your custom promises in same style with Backbone.Promise function. Don't worry, no magic here, it is just an alias for ES6 Promise function.

const promise = new Backbone.Promise((resolve, reject) => {
  // do a something async
  if (/* everything turned out fine */) {
    resolve('Stuff worked!');
  } else {
    reject(Error('It broke'));
  }
});

Keywords

FAQs

Package last updated on 23 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc