Code Monkey home page Code Monkey logo

iostore's People

Contributors

pingtest avatar yisbug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

iostore's Issues

null 会报错的问题,我需要转成空字符串

先感谢大神写的这个工具,使用中有些问题,还望解惑

    createStore({
        namespace: 'InventoryHkStore',
        list: {},
        async refreshList(){
            this.list = await axios.get('/xx');
        }
    });

举例如果 list. next_page_url 为 null 的时候,会抛出异常:
TypeError: Cannot convert undefined or null to object

把 null 转为空字符串就不会提示了

报错代码位置

/***/ "./node_modules/iostore/src/util.js":
/*!******************************************!*\
  !*** ./node_modules/iostore/src/util.js ***!
  \******************************************/
/*! exports provided: isFunction, isUndefined, isObject, isArray, isPromise, addProxy */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFunction", function() { return isFunction; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isUndefined", function() { return isUndefined; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isObject", function() { return isObject; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isArray", function() { return isArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPromise", function() { return isPromise; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addProxy", function() { return addProxy; });
const isFunction = fn => typeof fn === 'function';
const isUndefined = prop => typeof prop === 'undefined';
const isObject = o => typeof o === 'object';
const isArray = o => Array.isArray(o);
const isPromise = fn => {
  if (fn instanceof Promise) return true;
  return isObject(fn) && isFunction(fn.then);
};
const addProxy = (o, handler) => {
  if (!isObject(o)) return o;
  if (isArray(o)) {
    o.forEach((item, index) => {
      if (isObject(item)) {
        o[index] = addProxy(item, handler);
      }
    });
  } else if (isObject(o)) {
    Object.keys(o).forEach(key => {   // 这一行画了红线
      if (isObject(o[key])) {
        o[key] = addProxy(o[key], handler);
      }
    });
  }
  return new Proxy(o, handler);
};

不必要渲染的如何解决?

因为根据store名称来收集setState,从而触发渲染的
store任何一个属性变化都将触发所有依赖组件渲染,产生不必要的渲染

添加更自然的computed型变量支持

比如一个语言切换场景

export default createStore({
  namespace: 'IntlStore',
  locale: 'en-gb',
  m() {      // computed 型变量目前实现
    return messages[this.locale]
  },
  get m() { // 期望实现,
     return messages[this.locale]
  },
 setLocale(l) {
    this.locale = l
     // this.m = messages[l] // 一种丑陋的方式达成期望实现,每次locale变化时显式声明
  }
})

// usage in component
// ...
<p>m()['login']</p> // 目前实现
<p>m['login']</p> // 期望实现

出现这个报错是为什么You may need an appropriate loader to handle this file type.

ERROR in ./node_modules/iostore/src/createStore.js
Module parse failed: Unexpected token (9:26)
You may need an appropriate loader to handle this file type.
|
| export default config => {
| const { namespace = '', ...rest } = config;
| let service;
| let isChanged = false;
@ ./node_modules/iostore/src/index.js 2:0-40
@ ./src/workerjs/Navigation.js
@ multi (webpack)-dev-server/client?http://192.168.0.17:8888 ./src/workerjs/Navigation.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.