Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
flux-common-store
Advanced tools
Readme
Flux Common Store
npm install --save-dev flux-common-store
CHANGE_EVENT
(change)Constant event name, equals change
emitChange()
Emits CHANGE_EVENT
addChangeListener(callback)
: unsubscribeFunctionAdds callback
listener for CHANGE_EVENT and returns unsubscribe
function
removeChangeListener(callback)
Alternative way to unsubscribe from CHANGE_EVENT.
WARN For safety reasons, use unsubscribe
function returned by addChangeListener
instead
import FluxCommonStore from 'flux-common-store';
import Dispatcher from '../Dispatcher';
import Constants from '../Constants';
let todos = {};
const create = text => {
const id = Date.now();
todos[id] = {id: id, complete: false, text: text};
};
const destroy = id => delete todos[id];
const TodoStore = {
...FluxCommonStore,
getAll() {
return todos;
}
};
TodoStore.dispatcherIndex = Dispatcher.register(({actionType, payload}) => {
switch (actionType) {
case Constants.TODO_CREATE:
const text = payload.text.trim();
if (text !== '') {
create(text);
TodoStore.emitChange();
}
break;
case Constants.TODO_DESTROY:
destroy(payload.id);
TodoStore.emitChange();
break;
default:
// Empty
}
return true;
});
export default TodoStore;
import TodoStore from '../stores/TodoStore';
const TodoApp = React.createClass({
getInitialState() {
return {todos: TodoStore.getAll()};
},
componentDidMount() {
// Subscribe to TodoStore changes which returns `unsubscribe` function
this.unsubscribe = TodoStore.addChangeListener(this.onChange);
},
componentWillUnmount() {
this.unsubscribe();
},
onChange() {
this.setState({todos: TodoStore.getAll()});
},
render() {
return (
<ul>
{this.state.todos.map(todo => <li key={todo.id}>{todo.text}</li>)}
</ul>
);
}
});
export default TodoApp;
MIT
FAQs
Common Flux Store
The npm package flux-common-store receives a total of 11 weekly downloads. As such, flux-common-store popularity was classified as not popular.
We found that flux-common-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.