
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@computerwwwizards/observers
Advanced tools
A minimal TypeScript library for creating observable state containers with subscription capabilities.
A minimal TypeScript library for creating observable state containers with subscription capabilities.
ObservableStore<T>A basic store that holds a value of type T and notifies subscribers when that value changes.
DerivedStore<T, S>A store that derives its value from other observable stores, automatically updating when any source store changes.
ChildObservableStore<C, P>A store that is linked to a parent store, with its own value that can be updated independently or derived from the parent's value.
class ObservableStore<T> {
constructor(initialValue: T)
// Get the current value
getValue(): T
// Subscribe to changes
subscribe(listener: (currentValue: T) => void, emitCurrent = false): this
// Subscribe with a cleanup function
subscribeWithCleanup(listener: (currentValue: T) => void, emitCurrent = false): () => void
// Unsubscribe a listener
unsubscribe(listener: (currentValue: T) => void): this
// Update the store's value
update(updater: T | ((prev: T) => T)): this
}
class DerivedStore<T, S extends Record<string, any>> extends ObservableStore<T> {
constructor(
sources: SourcesRecord<S>,
deriveFn: (sourceValues: SourcesValues<S>, prevValue?: T) => T
)
// Get all source stores
getSources(): SourcesRecord<S>
// Get the current values of all source stores
getSourceValues(): SourcesValues<S>
// Clean up subscriptions
dispose(): this
// Override to support both direct updates and updates with source values
update(updater: T | ((prev: T, sourceValues?: SourcesValues<S>) => T)): this
}
class ChildObservableStore<C, P = C> extends ObservableStore<C> {
constructor(
initialValue: C,
parent: IObservableStore<P>,
onParentUpdate: (parentValue: P, childPrev: C) => C
)
// Change how parent updates affect this store
setOnParentUpdate(onParentUpdate: (parentValue: P, childPrev: C) => C): this
// Update with access to parent value
update(updater: C | ((childPrev: C, parentValue: P) => C)): this
// Clean up subscription to parent
dispose(): this
}
const counter = new ObservableStore(0);
// Subscribe to changes
counter.subscribe(value => console.log(`Counter: ${value}`));
// Update the value
counter.update(prev => prev + 1); // Logs: "Counter: 1"
counter.update(5); // Logs: "Counter: 5"
// You can also mutate the value directly if needed
counter.update(prev => {
prev.someProperty = newValue; // Direct mutation
return prev; // Return same reference
});
const userStore = new ObservableStore({ name: 'John', age: 30 });
const settingsStore = new ObservableStore({ theme: 'dark', fontSize: 14 });
const appState = new DerivedStore(
{ user: userStore, settings: settingsStore },
({ user, settings }) => ({
userName: user.name,
userAge: user.age,
isDarkMode: settings.theme === 'dark',
fontSize: settings.fontSize,
})
);
appState.subscribe(state => console.log(state));
userStore.update(prev => ({ ...prev, name: 'Jane' }));
// Logs: { userName: 'Jane', userAge: 30, isDarkMode: true, fontSize: 14 }
function useStore<T>(store: IObservableStore<T>) {
return useSyncExternalStore(
callback => store.subscribeWithCleanup(callback),
() => store.getValue()
);
}
function Counter() {
const count = useStore(counterStore);
return <div>{count}</div>;
}
The library doesn't catch errors from subscribers. If any subscriber throws, it will break the notification chain. This is an intentional design choice to keep the primitives minimal:
// Client code responsibility example
store.subscribe(value => {
try {
// Handle the update safely
processSafely(value);
} catch (error) {
// Handle errors locally
console.error('Error processing update:', error);
}
});
The library doesn't perform equality checks on values. Subscribers are responsible for determining if an update is meaningful:
let previousValue = null;
store.subscribe(value => {
// Client-side equality check
if (JSON.stringify(value) !== JSON.stringify(previousValue)) {
// Only process meaningful changes
doSomething(value);
previousValue = JSON.parse(JSON.stringify(value));
}
});
update methods, enabling custom error handling and edge case management per update.MIT
FAQs
A minimal TypeScript library for creating observable state containers with subscription capabilities.
We found that @computerwwwizards/observers 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.