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

disposable-component

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disposable-component - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

rx4.js

27

package.json
{
"name": "disposable-component",
"version": "0.2.0",
"version": "0.3.0",
"description": "A simple reactive API for mounting and unmounting components to the DOM",
"main": "lib/disposable-component.js",
"main": "rx4.js",
"repository": "https://github.com/CanopyTax/disposable-component",

@@ -10,13 +10,20 @@ "author": "Bret Little <bret.little@gmail.com>",

"scripts": {
"prepublish": "npm run build",
"build": "babel src --out-dir lib --source-maps",
"prepublish": "npm run dev",
"build": "webpack --mode production",
"test": "jest --coverage --config ./jest.json",
"test-watch": "jest --watch --config ./jest.json"
"test-watch": "jest --watch --config ./jest.json",
"dev": "webpack --mode development"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.46",
"@babel/core": "^7.0.0-beta.46",
"@babel/preset-env": "^7.0.0-beta.46",
"babel-core": "^7.0.0-0",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.4",
"babel-cli": "^6.26.0",
"babel-jest": "^21.2.0",
"babel-preset-es2015": "^6.24.1",
"jest": "^21.2.1",
"rx": "^4.1.0"
"rx": "^4.1.0",
"rxjs": "^6.3.3"
},

@@ -26,3 +33,7 @@ "files": [

"src"
]
],
"dependencies": {
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2"
}
}

@@ -1,2 +0,3 @@

import mountComponent from './disposable-component.js';
import mountComponent from './rx4.js';
import mountDisposableComponent from './rx6.js';

@@ -74,1 +75,61 @@ describe('Disposable Component', function() {

});
describe('Disposable Component rx6', function() {
it('should execute the mount life-cycle lazily', function() {
const mount = jasmine.createSpy();
const unmount = jasmine.createSpy();
mountDisposableComponent(mount, unmount);
expect(mount).not.toHaveBeenCalled();
expect(unmount).not.toHaveBeenCalled();
mountDisposableComponent(mount, unmount).subscribe(data => {
});
expect(mount).toHaveBeenCalled();
expect(unmount).not.toHaveBeenCalled();
});
it('should unmount when the subscription is disposed', function() {
const mount = jasmine.createSpy();
const unmount = jasmine.createSpy();
mountDisposableComponent(mount, unmount);
expect(mount).not.toHaveBeenCalled();
expect(unmount).not.toHaveBeenCalled();
mountDisposableComponent(mount, unmount).subscribe(data => {
}).unsubscribe();
expect(mount).toHaveBeenCalled();
expect(unmount).toHaveBeenCalled();
});
it('should publish data to the subscription', function() {
const mount = function(next, error, complete) {
next(1);
next(2);
};
const unmount = jasmine.createSpy();
const onData = jasmine.createSpy();
mountDisposableComponent(mount, unmount).subscribe(onData);
expect(onData).toHaveBeenCalledWith(1);
expect(onData).toHaveBeenCalledWith(2);
});
it('should publish errors to the subscription', function() {
const mount = function(next, complete, error) {
error('aah');
};
const unmount = jasmine.createSpy();
const error = jasmine.createSpy();
mountDisposableComponent(mount, unmount).subscribe(() => {}, error);
expect(error).toHaveBeenCalledWith('aah');
});
});
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