UNPKG

apprun

Version:

JavaScript library that has Elm inspired architecture, event pub-sub and components

87 lines 1.84 kB
{ "AppRun Application": { "prefix": "apprun", "body": [ "import app from 'apprun';", "", "const state = {}", "", "const view = (state) => {", "\treturn <div>", "\t\t{state}", "\t</div>", "}", "", "const update = {", "\t'#': (state) => state", "}", "", "app.start('${0:my-app}', state, view, update);" ], "description": "AppRun application" }, "AppRun Component": { "prefix": "component", "body": [ "import { app, Component } from 'apprun';", "", "export default class extends Component {", "\tstate = {}", "", "\tview = (state) => {", "\t\treturn <div>", "\t\t\t{state}", "\t\t</div>", "\t}", "", "\tupdate = {", "\t\t'#': (state) => state", "\t}", "}" ], "description": "AppRun application" }, "AppRun Pure Function Component": { "prefix": "pfc", "body": [ "const ${1:Name} = ({ ${2:prop} }) => {", "\treturn <div>", "\t\t$0", "\t</div>", "}" ], "description": "AppRun view function" }, "AppRun Update": { "prefix": "@on", "body": [ "@on() ${1:name} = (state, ${2:e}) => {", "\treturn { ...state, $2 }", "}" ], "description": "AppRun update function" }, "AppRun Log State": { "prefix": "log", "body": [ "console.log(${1:state})" ], "description": "Log state" }, "AppRun Event Publication": { "prefix": "run", "body": [ "{e => ${1|this,app|}.run('$2', e)}" ], "description": "AppRun publish event" }, "AppRun Event Subscription": { "prefix": "on", "body": [ "app.on('$1', ($2) => {", "\t$3", "})" ], "description": "AppRun subscribe to event" } }