Pulse
Application lifecycle state for TypeScript, React and React Native. One shared observation, immutable snapshots, and deduplicated foreground/background events.
Get started · Try the lifecycle lab · View on GitHub
Verification
The runtime and packaged consumer are tested automatically; physical-device and several browser lifecycle checks remain pending. See verification.
import { Pulse } from "@priemskiyyy/pulse";
import { browser } from "@priemskiyyy/pulse/browser";
export const pulse = new Pulse({ adapter: browser() });
pulse.on("foreground", (event) => {
console.log("Returned after", event.observedAway, "ms");
});
pulse.start();One Pulse owns one observation of its host. It reports a phase and an interaction as frozen snapshots, and foreground and background transitions between known phases.
The guarantee, and where it ends
Given the same ordered observations, clock samples and listener operations, Pulse produces the same snapshots and the same transitions. It does not promise that the platform reports every physical change, reports it at once, or gives JavaScript time to finish anything. A snapshot is the latest usable evidence under a documented mapping; unknown means there is none.
It is not a scheduler, an exit hook, a presence tracker or a security signal; see what Pulse is not.
Where to go next
- Getting started: ownership,
start(), passive subscriptions anddispose(). - States and transitions: the seven states, what counts as a transition, and the away time.
- Browser and React Native: what each adapter observes, and what it cannot.
- React: the hook, server rendering and hydration.
- Custom adapters, recipes and testing.
- Verification: what the tests prove, and what they do not.
- Decisions: where Pulse departs from its specification, and why.
- Architecture: the commit order and the invariants.