@dimjs/model-wxmp

The wxmp based state management of @dimjs

Usage no npm install needed!

<script type="module">
  import dimjsModelWxmp from 'https://cdn.skypack.dev/@dimjs/model-wxmp';
</script>

README

@dimjs/model-wxmp

the wxmp based state management of @dimjs

The usages

$ npm i @dimjs/model-wxmp

Features

  1. Full models api supports includes: actions, getActions,getInitialState, getState, subscribe, unsubscribe, useStore
  2. For big performance improvement, provides differential state data for setData.
  3. Share $models for multiple miniprogram page
  4. Shared the $models for Components Page
  5. Miniprogram Typed Api connect(models).Page|Component() supported.
  6. The detailed examples for full scenario .

Notes

  1. "noImplicitThis": true,
  2. In order to generated index.d.ts using import {} from @dimjs/model we must be setup some configurations as below.
// faltjs.dts.js
{
  compilationOptions: {
    followSymlinks: false,
  },
  entries: [
    libraries: {
      importedLibraries: ['@dimjs/model'],
    },
  ]
}
// tsconfig.json
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    // setup "paths" is {}
    "paths": {}
  }
}
  1. We must be manully install @types/wechat-miniprogram": "^3.2.0" in your project.

reference sites:

https://github.com/Tencent/westore/blob/master/packages/westore/utils/create.js https://github.com/cnyballk/wenaox https://github.com/charleyw/wechat-weapp-redux-todos/blob/master/src/utils/enhancedConnect.js

Notes

小程序编译引擎在压缩编译模式下会出现解析异常, 初步定位是小程序编译器的缺陷

 pluginConfigs: {
        terser: {
          options: {
            // 使用快速编译模式, 小程序工作正常.
            compress: false,
            mangle: true,
          },
        },
  ...