All Projects → t1ger-0527 → weapp-redux

t1ger-0527 / weapp-redux

Licence: MIT license
Unofficial Redux binding for weapp

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to weapp-redux

Nideshop
NideShop 开源微信小程序商城服务端 API(Node.js + ThinkJS)
Stars: ✭ 5,154 (+39546.15%)
Mutual labels:  weapp, wechat-app
Weapp Monument Valley
纪念碑谷 小程序 源码
Stars: ✭ 119 (+815.38%)
Mutual labels:  weapp, wechat-app
Masterwechatapp
『微信小程序』优秀教程、轮子、开源项目 资源汇总
Stars: ✭ 826 (+6253.85%)
Mutual labels:  weapp, wechat-app
wxapp-boilerplate
微信小程序开发脚手架 (ES6, Redux, Immutable-js, Async/await, Promise, Reselect, Babel, ESLint, Stylelint, Gulp ... )
Stars: ✭ 35 (+169.23%)
Mutual labels:  weapp, wechat-app
Weapp Ssha
企业官网 小程序 源码
Stars: ✭ 233 (+1692.31%)
Mutual labels:  weapp, wechat-app
Weapp Qrcode
Wechat miniapp generate qrcode image
Stars: ✭ 339 (+2507.69%)
Mutual labels:  weapp, wechat-app
Nideshop Mini Program
NideShop:基于Node.js+MySQL开发的开源微信小程序商城(微信小程序)
Stars: ✭ 7,115 (+54630.77%)
Mutual labels:  weapp, wechat-app
Eweapp
eweapp:ECShop非官方版微信小程序商城
Stars: ✭ 257 (+1876.92%)
Mutual labels:  weapp, wechat-app
Nxdc Milktea
一套仿奈雪の茶小程序的前端模板
Stars: ✭ 198 (+1423.08%)
Mutual labels:  weapp, wechat-app
Weapp Jump
跳一跳 小程序 源码
Stars: ✭ 173 (+1230.77%)
Mutual labels:  weapp, wechat-app
Alaweb
一套 Vue 代码,多端可用(H5、小程序、苹果App、安卓App、头条等)。系统含150+页面,200+组件(5端通用),30+元件(每个终端独立完成)
Stars: ✭ 837 (+6338.46%)
Mutual labels:  weapp, wechat-app
etym
English Etymology application
Stars: ✭ 86 (+561.54%)
Mutual labels:  weapp, wechat-app
Wxdraw
A lightweight canvas library which providing 2d draw for weapp 微信小程序2d动画库 😎 🐼
Stars: ✭ 1,625 (+12400%)
Mutual labels:  weapp, wechat-app
Weapp
🐧 微信小程序组件和功能封装,基于微信Component自定义组件开发
Stars: ✭ 235 (+1707.69%)
Mutual labels:  weapp, wechat-app
weapp wechat miniapp sdk
一个封装了微信小程序服务端接口的SDK
Stars: ✭ 102 (+684.62%)
Mutual labels:  weapp, wechat-app
we-rich
HTML转微信富文本节点, we just need rich, no text.
Stars: ✭ 36 (+176.92%)
Mutual labels:  weapp
wx-statuslayout
微信小程序页面状态切换组件
Stars: ✭ 24 (+84.62%)
Mutual labels:  weapp
mall-app
youlai-mall 微信小程序/H5/Android/iOS 移动应用端,uni-app终极跨平台前端框架。
Stars: ✭ 75 (+476.92%)
Mutual labels:  weapp
wxapp-hepan
清水河畔微信小程序
Stars: ✭ 19 (+46.15%)
Mutual labels:  wechat-app
we-app-typescript
A WeApp project template in TypeScript using VS Code
Stars: ✭ 15 (+15.38%)
Mutual labels:  weapp

Weapp Redux

Unofficial Redux binding for weapp(Wechat mini programs / 微信小程序). Performance optimized.

Installation

$ npm install --save weapp-redux-binding

Usage

To use redux, you need to bind your store to the app.

// your App.js
import Redux from 'redux'
import {Provider} from 'weapp-redux-binding'

const store = Redux.createStore(
  yourReducer,
  {},
)

App(
  Provider(store)({
    // your app config here, like below.
    onLaunch() {
      // do something
    }
  })
)

Just like react-redux, you can get the data from store, and bind actions to your page.

// your SomePage.js
import {connect} from 'weapp-redux-binding'
import {someActionBindingsHere} from 'actions/someData'

const pageConfig = {
  // your page config here, like below.
  onLoad() {
    // you can access your actions and data in pageConfig like this.
    this.someAction(this.data.someDataField)
  },
}

Page(
  connect(
    (state) => ({
      someDataField: state.someData.someField,
    }),
    {someAction: someActionBindingsHere}
  )(pageConfig)
)

You can access your data and actions in your index.wxml, for example:

<view bindtap="someAction">
  {{someDataField}}
</view>

Note

  • You can safely connect twice in your pageConfig definition, weapp-redux-binding makes sure your page will only respond to state change once.
  • Your page will not respond to state change once it leaves the screen (for example, wx.navigateTo), but it will reload with the latest state if it comes back to screen.
  • The setData is throttled, due to weapp's slow setData respond. The DELAY is 50ms.(production tested, 50ms is the perfect delay).
  • This binding is working well with all redux middlewares.

Who is using it?

Currently, all weapps in Zhihu is using this redux binding in production for over half year. Those apps are:

  • 知乎 Live weapp code
  • 知乎训练营 weapp code
  • 说话的地方 weapp code

Contributing

We use yarn to manage packages. So once you have downloaded this repo, run:

$ yarn

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].