disposable-component
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "disposable-component", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A simple reactive API for mounting and unmounting components to the DOM", | ||
"main": "lib/rx6.js", | ||
"main": "lib/rx4.js", | ||
"repository": "https://github.com/CanopyTax/disposable-component", | ||
@@ -19,16 +19,15 @@ "author": "Bret Little <bret.little@gmail.com>", | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.3", | ||
"@babel/core": "^7.4.3", | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-transform-modules-umd": "^7.2.0", | ||
"@babel/preset-env": "^7.4.3", | ||
"@babel/preset-env": "^7.2.3", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-jest": "^24.7.1", | ||
"browserslist-config-canopy": "^3.1.0", | ||
"babel-jest": "^23.6.0", | ||
"browserslist-config-canopy": "^2.0.0", | ||
"in-publish": "^2.0.0", | ||
"jest": "^24.7.1", | ||
"rimraf": "^2.6.3" | ||
"jest": "^23.6.0", | ||
"rimraf": "^2.6.2", | ||
"rx": "^4.1.0", | ||
"rxjs": "^6.3.3" | ||
}, | ||
"dependencies": { | ||
"rxjs": "^6.4.0" | ||
}, | ||
"files": [ | ||
@@ -35,0 +34,0 @@ "lib", |
@@ -12,3 +12,3 @@ # disposable-component | ||
``` | ||
npm install --save disposable-component | ||
npm install --save rx disposable-component | ||
``` | ||
@@ -21,9 +21,9 @@ | ||
```js | ||
import mountComponent from "disposable-component"; | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import mountComponent from "disposable-component"; | ||
function showModal(El, props) { | ||
return mountComponent( | ||
function mount(next, complete, error) { | ||
function mount(onNext, onCompleted, onError) { | ||
el = document.createElement("div"); | ||
@@ -33,3 +33,3 @@ document.body.appendChild(el); | ||
ReactDOM.render( | ||
<El {...props} close={complete} next={next} />, | ||
<El {...props} close={onCompleted} onNext={onNext} />, | ||
el | ||
@@ -49,4 +49,4 @@ ); | ||
<h1>My Modal</h1> | ||
<button onClick={this.props.complete}>Close</button> | ||
<button onClick={this.props.next.bind(null, 1)}>Save</button> | ||
<button onClick={this.props.onCompleted}>Close</button> | ||
<button onClick={this.props.onNext.bind(null, 1)}>Save</button> | ||
</div> | ||
@@ -59,3 +59,3 @@ ); | ||
subscription.unsubscribe(); // close the modal | ||
subscription.dispose(); // close the modal | ||
``` |
@@ -1,6 +0,6 @@ | ||
import { Observable } from "rxjs"; | ||
import { finalize } from "rxjs/operators"; | ||
import { Observable } from "rxjs" | ||
import { finalize } from "rxjs/operators" | ||
export default function mountDisposableComponent(mount, unmount) { | ||
return Observable.create(observer => { | ||
return Observable.create( observer => { | ||
mount( | ||
@@ -10,4 +10,6 @@ observer.next.bind(observer), | ||
observer.error.bind(observer) | ||
); | ||
}).pipe(finalize(unmount)); | ||
} | ||
) | ||
}).pipe( | ||
finalize(unmount) | ||
) | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11639
0
10
168
0
12
- Removedrxjs@^6.4.0
- Removedrxjs@6.6.7(transitive)
- Removedtslib@1.14.1(transitive)