0.1.8 • Published 4 years ago

micro-reaction-miniprogram v0.1.8

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

micro-reaction-miniprogram

one small ande strong state manage for miniprogram

Install

npm install micro-reaction-miniprogram

Usage

1 create global store

import { createStore, observable } from "micro-reaction-miniprogram"

const store = observable({
  credits: {
    count: 0
  }
});

export default createStore('home', store)

2 connect page with store

import homeStore from "../../store"

import { mapToData } from "micro-reaction-miniprogram"

const connect = mapToData((store) => ({ count: store.credits.count }), 'home')


Page(connect({}))

3 chanage store, page auto reaction

<button class="btn" type="primary" bindtap="onTap">Add</button>
Page(connect({
  onTap(e) {
    homeStore.credits.count++
  },
  onJump(e) {
    wx.navigateTo({
      url: "/pages/mine/mine"
    })
  }
}))

Demo

npm.io

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago