Skip to content
AppRun is a JavaScript library for developing high-performance and reliable web applications using the elm inspired architecture, events and components.
TypeScript JavaScript HTML
Branch: master
Clone or download
tskovlund and yysun Update README.md
Bump 2019 to 2020
Latest commit 5aee2ea Feb 20, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode :npm upgrade Nov 10, 2019
cli-templates update docs Dec 10, 2019
demo-html :npm upgrade and run build Feb 19, 2020
demo-node store AppRunVersions in global May 25, 2019
demo :npm upgrade and run build Feb 19, 2020
dist :npm upgrade and run build Feb 19, 2020
docs Merge branch 'master' into V2 / es6 Feb 19, 2020
esm :npm upgrade and run build Feb 19, 2020
src :npm upgrade and run build Feb 19, 2020
tests not to render when VDOM is boolean false Nov 15, 2019
.gitignore :compile Nov 2, 2019
.npmignore exclude demo folders from npm Jun 18, 2019
.travis.yml update travis ci config Aug 28, 2019
BACKERS.md ADD BACKER: Alfred Nerstu Feb 19, 2020
CHANGELOG.md :npm upgrade and run build Feb 19, 2020
CNAME Create CNAME Aug 13, 2018
LICENSE Initialize project Oct 7, 2016
README.md Update README.md Feb 20, 2020
WHATSNEW.md :update docs May 24, 2019
apprun-cli.js merge with master Mar 6, 2019
apprun.d.ts fix type def of VDOM Nov 15, 2019
index-wc.html fix web-component Mar 6, 2019
index.html add more examples Nov 6, 2019
logo.png Update docs Sep 10, 2017
package-lock.json :npm upgrade and run build Feb 19, 2020
package.json :npm upgrade and run build Feb 19, 2020
rollup.config.js add rollup commonjs plugin Nov 15, 2019
tsconfig.json fix child component id Sep 20, 2019
tslint.json disable tslint rule no-shadowed-variables Mar 3, 2019
typescriptreact.json update code snippet for component Jun 21, 2018
viewEngine.js not to use global.ssr Jul 10, 2018
webpack.config.js merge dev-tools Nov 2, 2019

README.md

AppRun Build NPM version Downloads License twitter Discord Chat

AppRun is a JavaScript library for building reliable, high-performance web applications using the Elm inspired Architecture, events, and components.

AppRun is a MIT-licensed open source project. Please consider supporting the project on Patreon. 👍❤️🙏

AppRun Benefits

  • Write less code
  • No proprietary syntax to learn
  • Compiler/transpiler is optional
  • State management and routing included
  • Run side-by-side with jQuery, chartjs, D3, lit-html ...

Applications built with AppRun have less lines of code, smaller js files, and better performance. See a comparison from A Real-World Comparison of Front-End Frameworks with Benchmarks (2019 update). You can also see the performance results compared to other frameworks and libraries in the js-framework-benchmark project.

AppRun Book from Apress

Order from Amazon

Architecture Concept

Application logic is broken down into three separated parts in the AppRun architecture.

  • State (a.k.a. Model) — the state of your application
  • View — a function to display the state
  • Update — a collection of event handlers to update the state

AppRun ties the three parts together and drives the applications using events.

Quick Start

AppRun is distributed on npm.

npm install apprun

You can also load AppRun directly from the unpkg.com CDN:

<script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>

Or use it as ES module from unpkg.com:

<script type="module">
  import { app, Component } from 'https://unpkg.com/apprun@next/esm/apprun-html?module';
</script>

Examples

Use AppRun in Browsers (HTML)

Below is a counter application using AppRun (Online Demo).

<html>
<head>
  <meta charset="utf-8">
  <title>Counter</title>
</head>
<body>
  <script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>
  <script>
    const state = 0;
    const view = state => {
      return `<div>
        <h1>${state}</h1>
        <button onclick='app.run("-1")'>-1</button>
        <button onclick='app.run("+1")'>+1</button>
      </div>`;
    };
    const update = {
      '+1': state => state + 1,
      '-1': state => state - 1
    };
    app.start(document.body, state, view, update);
  </script>
</body>
</html>

Web Component (lit-HTML)

Below is a counter application using AppRun (Online Demo).

<html>
<head>
  <meta charset="utf-8">
  <title>Counter Web Component</title>
</head>
<body>
  <wc-lit-html></wc-lit-html>
  <script type="module">
    import { app, Component } from 'https://unpkg.com/apprun@next/esm/apprun-html?module';
    class Counter extends Component {
      state = 0;
      view = (state) => html`<div>
      <h1>${state}</h1>
        <button @click=${()=>this.run("add", -1)}>-1</button>
        <button @click=${()=>this.run("add", +1)}>+1</button>
      </div>`;
      update =[
        ['add', (state, n) => state + n]
      ]
    }
    app.webComponent('wc-lit-html', Counter);
  </script>
</body>
</html>

Use JSX, Directive, TypeScript and Webpack

You can use AppRun with TypeScript and Webpack. Use the AppRun CLI to initialize a TypeScript and webpack configured project:

npx apprun --init
npm start

Below is a counter application using AppRun JSX and Directive that can be compiled and bundled using TypeScript and Webpack (Online Demo).

import app from 'apprun';
const state = 0;
const view = state => <div>
  <h1>{state}</h1>
  <button $onclick={state => state - 1}>+1</button>
  <button $onclick={state => state + 1}>+1</button>
</div>;
app.start(document.body, state, view);

AppRun Playground

Try the AppRun Playground to see more examples.

Developer Tools

CLI in Console

AppRun CLI also runs in console.

To use the AppRun dev-tools CLI, include the the dev-tools script.

<script src="https://unpkg.com/apprun@latest/dist/apprun-dev-tools.js"></script>

Dev-Tools Extensions

AppRun support the Redux DevTools Extension. To use the dev-tools, install the Redux DevTools Extension. You can monitor the events and states in the devtools.

app-dev-tools

VS Code Extension

AppRun has a code snippet extension for VS Code that you can install from the extension marketplace. It inserts AppRun code template for application, component and event handling.

app-dev-tools

Contribute

You can launch the webpack dev-server and the demo app from the demo folder with the following npm commands:

npm install
npm start

You can run the unit tests from the tests folder.

npm test

Unit tests can serve as functional specifications.

Finally, to build optimized js files to the dist folder, just run:

npm run build

Have fun and send pull requests.

License

MIT

Copyright (c) 2015-2020 Yiyi Sun

You can’t perform that action at this time.