capacitor-streaming-http
v0.1.4
Published
SSE request plugin for iOS and web
Maintainers
Readme
@capacitor/streaming-http
SSE request plugin for iOS and web
Install
npm install @capacitor/streaming-http
npx cap syncAPI
request(...)
request(options: { url: string; method?: string | undefined; headers?: { [key: string]: string; } | undefined; data?: any; hash_id: string; }) => Promise<void>发送HTTP请求并开始流式传输响应。 响应数据将通过onMessage事件监听器传递。
| Param | Type | Description |
| ------------- | ----------------------------------------------------------------------------------------------------------------- | ----------- |
| options | { url: string; method?: string; headers?: { [key: string]: string; }; data?: any; hash_id: string; } | 请求配置选项 |
Since: 1.0.0
close(...)
close(options: { hash_id?: string; }) => Promise<void>关闭指定的HTTP流式连接
| Param | Type | Description |
| ------------- | ---------------------------------- | ------------- |
| options | { hash_id?: string; } | 包含要关闭的连接的哈希ID |
Since: 1.0.0
addListener(string, ...)
addListener(eventName: string, callback: (data: any) => void) => Promise<PluginListenerHandle>添加事件监听器以接收流式传输事件
| Param | Type | Description |
| --------------- | ----------------------------------- | ----------- |
| eventName | string | 要监听的事件名称 |
| callback | (data: any) => void | 事件回调函数 |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
removeAllListeners()
removeAllListeners() => Promise<void>移除所有事件监听器
Since: 1.0.0
Interfaces
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
