https://github.com/rbndg/diffy-view
https://github.com/rbndg/diffy-view
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rbndg/diffy-view
- Owner: rbndg
- License: apache-2.0
- Created: 2020-05-02T11:02:43.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-14T13:41:39.000Z (about 5 years ago)
- Last Synced: 2024-12-07T09:22:32.660Z (5 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Diffy View
A simple class to extend and make React like components for CLI
### Example
``` js
const DiffyView = require("diffy-view")class View extends DiffyView {
render(){
return `Enter your name
${this.state.name || ""}
`
}
}const view = new View({state:{}})
view.on("enter-key",()=>{
console.log("Enter key pressed")
view.setState({
name : this.state.input
})
})view.on("update",(line)=>{
view.setState({
input:line
})
})view.forceRender()
```## Credit
[Diffy](https://github.com/mafintosh/diffy) by [Mafintosh](https://github.com/mafintosh)