npm.io
3.0.0 • Published 8 years ago

tunk-isolate

Licence
MIT
Version
3.0.0
Deps
0
Vulns
0
Weekly
0

tunk-isolate

数据传入store和从store取出的时候实现引用隔离,避免误操作引起非预期的数据变更

Usage

npm install tunk-isolate
import isolate from 'tunk-isolate'
tunk.use(isolate);

Config isolate : ['deep' | 'shallow' | 'none'] default:'deep'

// 全局配置debug,默认为 false
tunk.config({isolate: 'none'});

// 精确到模块配置是否debug
@create({isolate: 'deep'})
class demo {
    constructor(){
        ....
    }
    // 精确到某个动作配置是否debug
    @action({isolate: 'shallow'})
    sayHi(){
        ...
    }

}
deep

深克隆,隔离所有引用

JSON.parse(JSON.stringify(obj));
shallow

浅克隆,创建表层对象

Object.assign({}, obj);
none

不克隆,无隔离,效率最高