Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
reactive-box
Advanced tools
Minimalistic, fast, and highly efficient reactivity.
Hi friends! Today I will tell you how I came to this.
Redux has so many different functions, Mobx has mutable objects by default, Angular so heavy, Vue so strange, and other them so young :sweat_smile:
These funny thoughts served as fuel for writing the reaction core. So that everyone can make their own syntax for managing the state of the application in 100-150 lines.
It only three functions:
box
- is the container for an immutable value.sel
- is the cached selector (or computed value in another terminology) who will mark for recalculating If some of read inside boxes or selectors changed.expr
- is the expression who detects all boxes and selectors read inside and reacted If some of them changed.Counter with Node.js on RunKit
That counter with React:
import React from "react";
import { box, sel, expr } from "reactive-box";
const [getCounter, setCounter] = box(0);
const [getNext] = sel(() => getCounter() + 1);
const increment = () => setCounter(getCounter() + 1);
const decrement = () => setCounter(getCounter() - 1);
const useForceUpdate = () => {
return React.useReducer(() => [], [])[1];
};
const observe = <T extends React.FC<P>, P>(Component: T) =>
React.memo((props: P) => {
const forceUpdate = useForceUpdate();
const ref = React.useRef<[T, () => void]>();
if (!ref.current) {
ref.current = expr(Component, forceUpdate);
}
React.useEffect(() => ref.current![1], []);
return ref.current[0](props);
});
const Counter = observe(() => (
<p>
Counter: {getCounter()} (next value: {getNext()})
</p>
));
const Buttons = () => (
<p>
<button onClick={decrement}>Prev</button>
<button onClick={increment}>Next</button>
</p>
);
export const App = () => (
<>
<Counter />
<Buttons />
</>
);
It is minimal core for a big family of state managers' syntax. You can use the different syntax of your data flow on one big project, but the single core of your reactions provides the possibility for easy synchronization between them.
Examples of state managers' syntax:
Install
npm i reactive-box
Enjoy!
FAQs
Minimalistic, fast, and highly efficient reactivity
The npm package reactive-box receives a total of 82 weekly downloads. As such, reactive-box popularity was classified as not popular.
We found that reactive-box demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.