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

angular2-promise-buttons

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-promise-buttons - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

CONTRIBUTING.md

36

CHANGELOG.md

@@ -0,2 +1,38 @@

<a name="1.0.9"></a>
## [1.0.9](https://github.com/johannesjo/angular2-promise-buttons/compare/v1.0.7...v1.0.9) (2017-07-17)
### Bug Fixes
* add missing changelog ([0408a91](https://github.com/johannesjo/angular2-promise-buttons/commit/0408a91))
* weird issue making promiseBtn break inside form if handleCurrentBtnOnly is true by adding a timeout [#7](https://github.com/johannesjo/angular2-promise-buttons/issues/7) ([67b9870](https://github.com/johannesjo/angular2-promise-buttons/commit/67b9870))
### Features
* add example for an observable ([54965a0](https://github.com/johannesjo/angular2-promise-buttons/commit/54965a0))
* beautify demo page ([1205fee](https://github.com/johannesjo/angular2-promise-buttons/commit/1205fee))
* beautify demo page some more ([27e87f0](https://github.com/johannesjo/angular2-promise-buttons/commit/27e87f0))
<a name="1.0.8"></a>
## [1.0.8](https://github.com/johannesjo/angular2-promise-buttons/compare/v1.0.7...v1.0.8) (2017-07-17)
### Bug Fixes
* add missing changelog ([0408a91](https://github.com/johannesjo/angular2-promise-buttons/commit/0408a91))
* weird issue making promiseBtn break inside form if handleCurrentBtnOnly is true by adding a timeout [#7](https://github.com/johannesjo/angular2-promise-buttons/issues/7) ([67b9870](https://github.com/johannesjo/angular2-promise-buttons/commit/67b9870))
### Features
* add example for an observable ([54965a0](https://github.com/johannesjo/angular2-promise-buttons/commit/54965a0))
* beautify demo page ([1205fee](https://github.com/johannesjo/angular2-promise-buttons/commit/1205fee))
* beautify demo page some more ([27e87f0](https://github.com/johannesjo/angular2-promise-buttons/commit/27e87f0))
<a name="1.0.8"></a>
## [1.0.8](https://github.com/johannesjo/angular2-promise-buttons/compare/v1.0.7...v1.0.8) (2017-06-02)

@@ -3,0 +39,0 @@

8

dist/promise-btn.directive.d.ts

@@ -0,2 +1,5 @@

/// <reference types="bluebird" />
import { AfterContentInit, ElementRef, OnDestroy } from '@angular/core';
import 'rxjs/add/operator/toPromise';
import * as BlueBird from 'bluebird';
import { PromiseBtnConfig } from './promise-btn-config';

@@ -9,3 +12,3 @@ export declare class PromiseBtnDirective implements OnDestroy, AfterContentInit {

btnEl: HTMLElement;
promise: any;
promise: (Promise<any> & BlueBird<any>);
constructor(el: ElementRef, userCfg: any);

@@ -57,6 +60,5 @@ promiseBtn: any;

* this.cfg.minDuration into account if given.
* @param {Object}promise
* @param {Object}btnEl
*/
initPromiseHandler(promise: any, btnEl: HTMLElement): void;
initPromiseHandler(btnEl: HTMLElement): void;
/**

@@ -63,0 +65,0 @@ * $compile and append the spinner template to the button.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var Observable_1 = require("rxjs/Observable");
require("rxjs/add/operator/toPromise");
var default_promise_btn_config_1 = require("./default-promise-btn-config");

@@ -14,4 +16,14 @@ var user_cfg_1 = require("./user-cfg");

Object.defineProperty(PromiseBtnDirective.prototype, "promiseBtn", {
set: function (promise) {
this.promise = promise;
set: function (request) {
var isObservable = request instanceof Observable_1.Observable;
var isPromise = request instanceof Promise || (request !== null &&
typeof request === 'object' &&
typeof request.then === 'function' &&
typeof request.catch === 'function');
if (isObservable) {
this.promise = request.toPromise();
}
else if (isPromise) {
this.promise = request;
}
this.checkAndInitPromiseHandler(this.btnEl);

@@ -47,4 +59,5 @@ },

PromiseBtnDirective.prototype.checkAndInitPromiseHandler = function (btnEl) {
// check if element and promise is set
if (btnEl && this.promise) {
this.initPromiseHandler(this.promise, btnEl);
this.initPromiseHandler(btnEl);
}

@@ -108,11 +121,7 @@ };

* this.cfg.minDuration into account if given.
* @param {Object}promise
* @param {Object}btnEl
*/
PromiseBtnDirective.prototype.initPromiseHandler = function (promise, btnEl) {
PromiseBtnDirective.prototype.initPromiseHandler = function (btnEl) {
var _this = this;
// return if something else then a promise is passed
if (!promise || !promise.then) {
return;
}
var promise = this.promise;
// watch promise to resolve or fail

@@ -135,2 +144,3 @@ this.isMinDurationTimeoutDone = false;

}
// native Promise doesn't have finally
if (promise.finally) {

@@ -163,2 +173,6 @@ promise.finally(resolveLoadingState);

btnEl.addEventListener(this.cfg.CLICK_EVENT, function () {
// return if something else than a promise is passed
if (!_this.promise) {
return;
}
// due to some really weird reasons, we need a timeout

@@ -165,0 +179,0 @@ // to let the model still update when a button

{
"name": "angular2-promise-buttons",
"version": "1.0.8",
"version": "1.0.9",
"license": "MIT",

@@ -55,6 +55,9 @@ "repository": {

"@angular/router": "^4.0.0",
"@types/bluebird": "^3.5.8",
"@types/core-js": "^0.9.41",
"@types/jasmine": "2.5.38",
"@types/jquery": "^3.2.8",
"@types/node": "~6.0.60",
"angular2-template-loader": "^0.6.2",
"bluebird": "^3.5.0",
"bootstrap": "^3.3.7",

@@ -71,2 +74,3 @@ "bootstrap-material-design": "^0.5.10",

"jasmine-spec-reporter": "~3.2.0",
"jquery": "^3.2.1",
"karma": "~1.4.1",

@@ -85,3 +89,3 @@ "karma-chrome-launcher": "~2.0.0",

"tslint": "~4.5.0",
"typescript": "~2.2.0",
"typescript": "~2.3.0",
"wallaby-webpack": "0.0.38",

@@ -88,0 +92,0 @@ "web-animations-js": "^2.2.5",

@@ -86,1 +86,3 @@ [![npm version](https://badge.fury.io/js/angular2-promise-buttons.svg)](https://badge.fury.io/js/angular2-promise-buttons)

```
## Contributing
Contribution guidelines: [CONTRIBUTING.md](https://github.com/johannesjo/angular2-promise-buttons/blob/master/CONTRIBUTING.md)

Sorry, the diff of this file is not supported yet

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