Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@solid-primitives/static-store
Advanced tools
Primitives for creating small reactive objects that doesn't change their shape over time - don't need a proxy wrapper.
Primitives for creating small reactive objects that doesn't change their shape over time - don't need a proxy wrapper.
createStaticStore
- Creates a writable static store object.createDerivedStaticStore
- Creates a static store that is derived from a source function.npm install @solid-primitives/static-store
# or
yarn add @solid-primitives/static-store
# or
pnpm add @solid-primitives/static-store
createStaticStore
Creates read-only object that is shallowly reactive — only reactive on its first level and for the enumerable properties specified in the initial value — and a setter. It behaves similarly to createStore, but with limited features to keep it simple and performant. Designed to be used for reactive objects with static keys and dynamic values, like reactive Event State, location, etc.
It takes a single argument - an initial value. It returns a tuple with the store object and a setter function.
import { createStaticStore } from "@solid-primitives/static-store";
const [size, setSize] = createStaticStore({ width: 0, height: 0 });
createEffect(() => {
// both of these are separate signals, that can be listened to independently
console.log(size.width, size.height);
});
// changing the property will trigger observers of that property only
setSize("width", 100);
el.addEventListener("resize", () => {
// passed object will get merged with the existing store
setSize({ width: el.offsetWidth, height: el.offsetHeight });
});
// adding a new property will NOT work
// the shape of the store is static
setSize("new-property", "value");
createDerivedStaticStore
A derived version of the createStaticStore
. It will use the update function to derive the value of the store. It will only update when the dependencies of the update function change.
It works similarly to the createMemo
primitive and it takes the same arguments, but it returns a reactive object rather than an accessor function.
// source
const [size, setSize] = createSignal({ width: 0, height: 0 });
const store = createDerivedStaticStore(size);
createEffect(() => {
// both of these are separate signals, that can be listened to independently
console.log(store.width, store.height);
});
el.addEventListener("resize", () => {
// only the changed properties that changed will trigger their observers
setSize(p => ({ ...p, height: el.offsetHeight }));
});
createHydratableStaticStore
A "hydratable" version of the createStaticStore
- it will use the serverValue
on the server and the update
function on the client. If initialized during hydration it will use serverValue
as the initial value and update it once hydration is complete.
Warning This primitive version is experimental, and mostly used internally by other primitives. It is not recommended to use it directly.
import { createHydratableStaticStore } from "@solid-primitives/static-store";
// reads from the DOM
const getSize = () => ({ width: el.offsetWidth, height: el.offsetHeight });
const [size, setSize] = createHydratableStaticStore(
// server fallback value
{ width: 0, height: 0 },
// update function (called onMount)
() => {
el.addEventListener("resize", () => setSize(getSize()));
return getSize();
},
);
createEffect(() => {
console.log(size.width, size.height);
});
See CHANGELOG.md
FAQs
Primitives for creating small reactive objects that doesn't change their shape over time - don't need a proxy wrapper.
The npm package @solid-primitives/static-store receives a total of 26,516 weekly downloads. As such, @solid-primitives/static-store popularity was classified as popular.
We found that @solid-primitives/static-store demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.