New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-observe

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-observe - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

53

dist/angular-observe.js

@@ -63,3 +63,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

mod.directive('observe', ['$compile', function ($compile) {
mod.directive('observe', ['$compile', '$timeout', function ($compile, $timeout) {
return {

@@ -75,6 +75,17 @@ restrict: 'EA',

link: function ($scope, $element, $attrs, ctl, $transclude) {
var currentState;
var stateLinkFunctions = {};
var source = $scope.$eval($attrs.observe || $attrs.source);
if (!source) {
console.warn('The `observable` directive requires a source observable.');
return;
}
// Subscribe to the observable
var stateLinkFunctions = {};
var currentState;
var observable = $scope.$eval($attrs.observe || $attrs.source);
var observable = typeof source.subscribe === 'function'
? source
: typeof source.then === 'function'
? liftPromise(source)
: liftValue(source);
var subscription = observable.subscribe(onNext, onError, onComplete);

@@ -126,6 +137,33 @@

function liftPromise(source) {
return {
subscribe: function (onNext, onError, onComplete) {
source.then(onNext, onError, onNext)
.catch(function (reason) {
return reason;
})
.then(onComplete);
return {
unsubscribe: Angular.noop,
};
}
};
}
function liftValue(source) {
return {
subscribe: function (onNext, onError, onComplete) {
$timeout(onNext.bind(null, source), 0, false)
.then(onComplete);
return {
unsubscribe: Angular.noop,
};
}
};
}
function setState(state, skipDigest) {
if (state !== currentState) {
$element.empty();
var linkFunction = stateLinkFunctions[state];

@@ -139,2 +177,3 @@

$element.empty();
$element.append(replacement);

@@ -145,3 +184,3 @@

if (!skipDigest) {
if (!skipDigest && !$scope.$root.$$phase) {
$scope.$digest(true);

@@ -148,0 +187,0 @@ }

2

dist/angular-observe.min.js

@@ -1,1 +0,1 @@

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("angular")):"function"==typeof define&&define.amd?define(["angular"],r):"object"==typeof exports?exports.AngularObserve=r(require("angular")):e.AngularObserve=r(e.angular)}(this,function(e){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){var t=n(1);e.exports="filearts.angularObserve";var o=t.module(e.exports,[]);o.directive("observe",["$compile",function(e){return{restrict:"EA",scope:!0,transclude:{loading:"?loading",active:"?active",complete:"?complete",error:"?error"},link:function(r,n,t,o,i){function l(e){r.$value=e,s("active")}function u(e){s("complete")}function a(e){r.$error=e,s("error")}function c(r,n,t){var o=n?t.contents():t;if(o.length){var i=e(o);f[r]=i}}function s(e,t){if(e!==d){n.empty();var o=f[e];if(!o)return;var i=o(r);n.append(i),d=e}t||r.$digest(!0)}var d,f={},p=r.$eval(t.observe||t.source),v=p.subscribe(l,a,u);i(c.bind(null,"active",!1),null,""),i(c.bind(null,"loading",!0),null,"loading"),i(c.bind(null,"active",!0),null,"active"),i(c.bind(null,"complete",!0),null,"complete"),i(c.bind(null,"error",!0),null,"error"),f.active||console.warn("The `observable` directive requires at least one child element."),s("loading",!0),r.$on("$destroy",function(){v.unsubscribe()})}}}])},function(r,n){r.exports=e}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("angular")):"function"==typeof define&&define.amd?define(["angular"],n):"object"==typeof exports?exports.AngularObserve=n(require("angular")):e.AngularObserve=n(e.angular)}(this,function(e){return function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){var t=r(1);e.exports="filearts.angularObserve";var o=t.module(e.exports,[]);o.directive("observe",["$compile","$timeout",function(e,n){return{restrict:"EA",scope:!0,transclude:{loading:"?loading",active:"?active",complete:"?complete",error:"?error"},link:function(r,o,i,u,c){function l(e){r.$value=e,p("active")}function a(e){p("complete")}function s(e){r.$error=e,p("error")}function f(n,r,t){var o=r?t.contents():t;if(o.length){var i=e(o);g[n]=i}}function b(e){return{subscribe:function(n,r,o){return e.then(n,r,n)["catch"](function(e){return e}).then(o),{unsubscribe:t.noop}}}}function d(e){return{subscribe:function(r,o,i){return n(r.bind(null,e),0,!1).then(i),{unsubscribe:t.noop}}}}function p(e,n){if(e!==v){var t=g[e];if(!t)return;var i=t(r);o.empty(),o.append(i),v=e}n||r.$root.$$phase||r.$digest(!0)}var v,g={},m=r.$eval(i.observe||i.source);if(!m)return void console.warn("The `observable` directive requires a source observable.");var x="function"==typeof m.subscribe?m:"function"==typeof m.then?b(m):d(m),h=x.subscribe(l,s,a);c(f.bind(null,"active",!1),null,""),c(f.bind(null,"loading",!0),null,"loading"),c(f.bind(null,"active",!0),null,"active"),c(f.bind(null,"complete",!0),null,"complete"),c(f.bind(null,"error",!0),null,"error"),g.active||console.warn("The `observable` directive requires at least one child element."),p("loading",!0),r.$on("$destroy",function(){h.unsubscribe()})}}}])},function(n,r){n.exports=e}])});
{
"name": "angular-observe",
"version": "1.0.1",
"version": "1.1.0",
"description": "Angular directive for representing the different states of an Observable.",

@@ -5,0 +5,0 @@ "main": "./dist/angular-observe.js",

@@ -7,3 +7,3 @@ var Angular = require('angular');

mod.directive('observe', ['$compile', function ($compile) {
mod.directive('observe', ['$compile', '$timeout', function ($compile, $timeout) {
return {

@@ -19,6 +19,17 @@ restrict: 'EA',

link: function ($scope, $element, $attrs, ctl, $transclude) {
var currentState;
var stateLinkFunctions = {};
var source = $scope.$eval($attrs.observe || $attrs.source);
if (!source) {
console.warn('The `observable` directive requires a source observable.');
return;
}
// Subscribe to the observable
var stateLinkFunctions = {};
var currentState;
var observable = $scope.$eval($attrs.observe || $attrs.source);
var observable = typeof source.subscribe === 'function'
? source
: typeof source.then === 'function'
? liftPromise(source)
: liftValue(source);
var subscription = observable.subscribe(onNext, onError, onComplete);

@@ -70,6 +81,33 @@

function liftPromise(source) {
return {
subscribe: function (onNext, onError, onComplete) {
source.then(onNext, onError, onNext)
.catch(function (reason) {
return reason;
})
.then(onComplete);
return {
unsubscribe: Angular.noop,
};
}
};
}
function liftValue(source) {
return {
subscribe: function (onNext, onError, onComplete) {
$timeout(onNext.bind(null, source), 0, false)
.then(onComplete);
return {
unsubscribe: Angular.noop,
};
}
};
}
function setState(state, skipDigest) {
if (state !== currentState) {
$element.empty();
var linkFunction = stateLinkFunctions[state];

@@ -83,2 +121,3 @@

$element.empty();
$element.append(replacement);

@@ -89,3 +128,3 @@

if (!skipDigest) {
if (!skipDigest && !$scope.$root.$$phase) {
$scope.$digest(true);

@@ -92,0 +131,0 @@ }

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