ReselectRedux 的选择器库
Reselect 是一个 Redux 的选择器库,灵感来源于 NuclearJS 。
Selector 可以计算衍生的数据,可以让 Redux 存储尽可能少的 state 。
Selector 非常高效,除非某个参数发生变化,否则不会发生计算过程。
Selector 是可组合的,它们可以输入、传递到其他的选择器。
示例:
import { createSelector } from 'reselect' const shopItemsSelector = state => state.shop.items const taxPercentSelector = state => state.shop.taxPercent const subtotalSelector = createSelector( shopItemsSelector, items => items.reduce((acc, item) => acc + item.value, 0) ) const taxSelector = createSelector( subtotalSelector, taxPercentSelector, (subtotal, taxPercent) => subtotal * (taxPercent / 100) ) export const totalSelector = createSelector( subtotalSelector, taxSelector, (subtotal, tax) => ({ total: subtotal + tax }) ) let exampleState = { shop: { taxPercent: 8, items: [ { name: 'apple', value: 1.20 }, { name: 'orange', value: 0.95 }, ] } } console.log(subtotalSelector(exampleState)) // 2.15 console.log(taxSelector(exampleState)) // 0.172 console.log(totalSelector(exampleState)) // { total: 2.322 }
评论
NWMatcherJavaScript 的选择器引擎
NWMatcher 是一个基于JavaScript的选择器引擎,在DOM中通过提供CSS选择器得到匹配的元素,也被用于验证指定元素是否符合某个CSS选择器。目前NWMatcher既支持浏览器(通过创建
NWMatcherJavaScript 的选择器引擎
0
SizzlejQuery的选择器引擎
jquery从1.3开始,使用了新的选择器–sizzle。效率超过了以前的jquery版本以及目前能见到的其他选择器。Sizzle是jQuery作者JohnResig新写的DOM选择器引擎,速度号称业
SizzlejQuery的选择器引擎
0
AndroidPicker安卓选择器类库
AndroidPicker是安卓选择器类库,包括日期时间选择器、一二三级联动选择器、颜色选择器、文件目录选择器。详见:README.md代码示例日期选择器: DateTimePicker
AndroidPicker安卓选择器类库
0