@hyperfrontend/features/hosteeHostee
Hostee-side SDK for feature apps — feature initialization, contract declaration, and lifecycle.
import { createFeature } from '@hyperfrontend/features/hostee'
const feature = createFeature({
name: 'clock',
contract: {
emitted: [{ type: 'tick' }],
accepted: [{ type: 'set-timezone' }],
},
})
await feature.ready()
feature.on('set-timezone', ({ tz }) => render(tz))
setInterval(() => feature.send('tick', Date.now()), 1000)
API
| Export | Purpose |
|---|---|
createFeature | Connect a feature app to its host; returns send/on/ready/close. |
FeatureHandle | Type of the handle returned by createFeature. |
ready() resolves once the host connection is established. send emits a contract action to the host; on subscribes to host messages and the open/close/error lifecycle events. close disconnects from the host.
API Reference
ƒ Functions
Initializes a feature app on the hostee side and waits for the host connection.
Creates a nexus broker for the feature, resolves the host window, and returns a handle for messaging and lifecycle.
Creates a nexus broker for the feature, resolves the host window, and returns a handle for messaging and lifecycle.
Parameters
| Name | Type | Description |
|---|---|---|
§options | FeatureOptions | Feature name and contract. |
Returns
FeatureHandleA handle exposing
send, on, ready, and close.Example
Initializing a clock feature
const feature = createFeature({ name: 'clock', contract })
feature.ready().then(() => feature.send('timeUpdated', { time: Date.now() }))
feature.on('setTimezone', (data) => console.log(data))