@nighthq/host
v0.1.1
Published
The effect boundary: performs what a model declares — history, titles, announcements, focus.
Downloads
3,325
Readme
@nighthq/host
The effect boundary: performs what a model declares — history, titles, announcements, focus.
A @nighthq/model protocol never touches the DOM. It declares effects, and
a handler set here makes them happen — in a browser, in a test, or not at all.
Swapping the set is the whole difference between production and a unit test,
which is why a protocol that navigates is testable with no DOM.
import { bindToBrowser, browserHandlers, browserInitial, createHost } from '@nighthq/host';
export const host = createHost({
routes: ROUTES,
handlers: browserHandlers({ titleSuffix: ' · Watch' }),
...browserInitial() // address AND history depth, read from the browser
});
bindToBrowser(host);The scope is deliberately narrow: handlers for the closed effect union, and
the route registry (sitemap, navRoutes) with its URL grammar (hashCodec
— the codec is the only writer of route addresses). Not data fetching, not
layouts, not the build.
recordingHandlers is the test half: every effect a protocol declares,
written down instead of performed, so a test asserts on intent.
MIT © Bitspark
