Installations
npm install reflux-partial
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
4.1.1
NPM Version
2.14.4
Score
38.3
Supply Chain
93.3
Quality
74.2
Maintenance
50
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
4,254
Last day
0%
1
Compared to previous day
Last week
200%
3
Compared to previous week
Last month
0%
5
Compared to previous month
Last year
-50%
127
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
2
Dev Dependencies
2
reflux-part
##What is it
Plugin for reflux-core to use part of state, extends at
1. Reflux.connectPart(store, propNames)
You can connect part of state from store to component. Because the componet only care about part of state, just like you only care about one of many girls in your class.
你可以将store中的部分state连接到组件中,因为组件很可能只关心部分state,就好像你只关注你们班里的某个女孩。
2. Store.triggerPart(partState)
You can update part of state, not full of state. This method will help you merge new part and old part in state, and update full of state automatically. For example, you have a state about user(include username, password, birthday, address), but you only change password, so just trigger password.
你可以更新部分state,而不是全部state。该方法可以帮你合并state中的新旧部分,从而自动更新全部state,保证旧部分的state不丢失。例如,你有一个关于用户的state(包含用户名、密码、生日、地址),但是你只修改了密码,因此只需要触发密码的更新。
3. Store.getState()
You can read the state by this.getState() in the store, just like this.state in the component.
你可以在store中用 this.getState() 来获得state,就好像你在组件中用 this.state 来获得state。
##How to use it
1. Install
npm install reflux-part@latest --save
2. Extend Reflux
To install partial state functionality do the following in your application's bootstrapper or in a file:
1import Reflux from "reflux"; 2import RefluxPartial from "reflux-partial"; 3 4// Extend connect 5Reflux.connectPart = RefluxPartial.connect; 6 7// Extend store 8Reflux.StoreMethods = Object.assign(Reflux.StoreMethods, RefluxPartial.StoreMethods); 9 10export default Reflux;
3. Store
Define a store, and use triggerPart() to update part of state, use getState() to get full of state.
import Reflux from '../reflux'; // The Reflux extends by Step 2
import { notification } from 'antd';
var MenuActions = require('../actions/menu');
import api from '../api';
var MenuStore = Reflux.createStore({
// this will set up listeners to all publishers in UserActions, using onKeyname (or keyname) as callbacks
listenables: [MenuActions],
getInitialState: function() {
return {
currentIndex: 0, // 当前点击的菜单key
items: [], // 两级的菜单,以children来关联
navpath: [] // 打开的菜单路径
};
},
// 获得菜单
onGetAllMenu: function(){
api.post('/menu')
.then((data) => {
this.triggerPart({items: data.menus}); // update part of state
}).catch((e) => {
notification.error({
message: 'Get all menu fail',
description: e
});
});
},
// 更新菜单路径
onUpdateNavPath: function(navpath, key){
const {items} = this.getState(); // get state in store
this.triggerPart({
currentIndex: key,
navpath
});
},
});
module.exports = MenuStore;
4. Component
Define a component, and connect store's state with this componet.
import React from 'react';
import ReactMixin from 'react-mixin';
import Reflux from '../../reflux'; // The Reflux extends by Step 2
import MenuActions from '../../actions/menu';
import MenuStore from '../../store/menu';
class Sidebar extends React.Component {
componentDidMount () {
MenuActions.getAllMenu();
}
render () {
const { items, currentIndex } = this.state;
return (
<ol>
{items.map((item, i) => {
return <li>{item.name}</li>
})}
</ol>
)
}
}
// connect MenuStore's partial state('items' and 'currentIndex' property) with component Sidebar
// 将MenuStore中state的 'items' 与 'currentIndex' 属性,绑定到Sidebar组件中
ReactMixin.onClass(Sidebar, Reflux.connectPart(MenuStore,['items', 'currentIndex']));
export default Sidebar;
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More