From 2c49a52a41a30ae844376561de95f0c851d19f73 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 31 Jul 2020 01:15:22 -0400 Subject: [PATCH] Renamed and documented experimental fetchData function. --- packages/web/src.ts/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/web/src.ts/index.ts b/packages/web/src.ts/index.ts index be0bb98e38..d5330f9fa6 100644 --- a/packages/web/src.ts/index.ts +++ b/packages/web/src.ts/index.ts @@ -59,7 +59,13 @@ export type FetchJsonResponse = { type Header = { key: string, value: string }; -export function fetchData(connection: string | ConnectionInfo, body?: Uint8Array, processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T): Promise { +// This API is still a work in progress; the future changes will likely be: +// - ConnectionInfo => FetchDataRequest +// - FetchDataRequest.body? = string | Uint8Array | { contentType: string, data: string | Uint8Array } +// - If string => text/plain, Uint8Array => application/octet-stream (if content-type unspecified) +// - FetchDataRequest.processFunc = (body: Uint8Array, response: FetchDataResponse) => T +// For this reason, it should be considered internal until the API is finalized +export function _fetchData(connection: string | ConnectionInfo, body?: Uint8Array, processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T): Promise { // How many times to retry in the event of a throttle const attemptLimit = (typeof(connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit: 12; @@ -320,7 +326,7 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr connection = updated; } - return fetchData(connection, body, processJsonFunc); + return _fetchData(connection, body, processJsonFunc); } export function poll(func: () => Promise, options?: PollOptions): Promise {