Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@dhmk/atom
Advanced tools
Lightweight mobx-like observable values, computed values and side-effects
MobX-like observable atoms, computeds and observers.
Install: npm install @dhmk/atom
import { observable, observe, act } from "@dhmk-atom";
const x = observable({
id: 123,
get computedProp() {
return this.id.toString();
},
});
const dispose = observe(() => console.log(x.computedProp));
act(() => (x.id = 456));
dispose();
atom(value: T, opts?: AtomOptions): WritableAtom<T>
Creates a value atom which is similar to MobX observable.box(value, { deep: false }).
type AtomOptions = {
equals?: (next: T, prev: T) => boolean;
onBecomeObserved?: () => void;
onBecomeUnobserved?: () => void;
set?: (setter: (x: T) => void) => (x: T) => void;
};
type WritableAtom<T> = {
(): T;
get(): T;
set(x: T): void;
};
atom(fn: () => T, opts?: ComputedAtomOptions): Atom<T>
Creates a computed atom which is similar to MobX computed.
type ComputedAtomOptions = {
equals?: (next: T, prev: T) => boolean;
onBecomeObserved?: () => void;
onBecomeUnobserved?: () => void;
};
type ComputedAtom<T> = {
(): T;
get(): T;
};
observable(x)
Creates observable object or array. See also observableObject
, observableArray
, as
.
observe(fn: (self: Observer) => void, opts?: ObserverOptions): Observer
Similar to MobX autorun.
type ObserverOptions = {
scheduler?: (run: Function) => void;
onBecomeObserved?: () => void;
onBecomeUnobserved?: () => void;
};
type Observer = {
// dispose
(): void;
// schedule observer for execution even if no tracked atoms were changed
invalidate(): void;
readonly isInitial: boolean;
};
act(fn: () => T): T
MobX runInAction.
untracked(fn: () => T): T
MobX untracked.
as(x: { get, set? })
Instructs observableObject
to initialize property as given object instead of default behavior.
observableObject(x)
observableObject({
id: 123,
get computedProp() {
return this.id.toString();
},
withOptions: as(atom("abc", { onBecomeObserved() {} })),
});
observableArray(x)
ValueAtom
ComputedAtom
EffectAtom
FAQs
Lightweight mobx-like observable values, computed values and side-effects
The npm package @dhmk/atom receives a total of 21 weekly downloads. As such, @dhmk/atom popularity was classified as not popular.
We found that @dhmk/atom demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.