apprun-reactive

AppRun plugin that provides the @reactive decorator

Usage no npm install needed!

<script type="module">
  import apprunReactive from 'https://cdn.skypack.dev/apprun-reactive';
</script>

README

AppRun Reactive Plugin

Introduction

This plugin provides the @reactive decorator to make AppRun components reactive.

import { app, Component } from 'apprun';
import { reactive } from 'apprun-reactive';

@reactive
export default class Counter extends Component {
  state = { num: 0 }

  add = num => {
    this.state.num = this.state.num + num;
  }

  view = state => <>
    <div>{state.num}</div>
    <button onclick={()=>this.add(-1)}>-1</button>
    <button onclick={()=>this.add(+1)}>+1</button>
  </>
}
new Counter().start(document.body);

Install

npm i apprun-reactive
  • Use npm start to start the dev server
  • Use npm test to run unit tests
  • Use npm run build to build for production

Have fun and send pull requests.

License

MIT

Copyright (c) 2015-2019 Yiyi Sun