From f0935b92de554212779e0307669d92092a345527 Mon Sep 17 00:00:00 2001 From: Zlatkovsky Date: Fri, 11 Jan 2019 17:10:30 -0800 Subject: [PATCH] Add dictionary-based overload for `CustomFunctions.associate` --- .../custom-functions-runtime-tests.ts | 5 +++++ types/custom-functions-runtime/index.d.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 0a3c482505..8f54ee4f5c 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -5,6 +5,11 @@ function add10(n: number) { CustomFunctions.associate('ADD10', add10); +CustomFunctions.associate({ + ADD10: add10, + RANDOM: (n: number) => n * Math.random() +}); + async function getStockValues(ticker: string): Promise { const response = await fetch(`myService.com/prices/${ticker}`); return (await response.json())["price"]; diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index f78f6a45c4..174308c131 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -16,9 +16,14 @@ Copyright (c) Microsoft Corporation declare namespace CustomFunctions { /** * @beta - * Ties together the function's JavaScript name with the JSON id property + * Associates the JavaScript function to the name given by the "id" property in the metadata JSON file. */ function associate(id: string, functionObject: Function): void; + /** + * @beta + * Associates the JavaScript functions to the names given by the "id" properties in the metadata JSON file. + */ + function associate(mappings: { [key: string]: Function }): void; /** * A handler passed automatically as the last parameter @@ -28,7 +33,6 @@ declare namespace CustomFunctions { * to handle what happens when the function stops streaming. * @beta */ - interface StreamingHandler extends CancelableHandler { /** * Sets the returned result for a streaming custom function. @@ -36,6 +40,7 @@ declare namespace CustomFunctions { */ setResult: (value: T | Error) => void; } + /** * @beta * CancelableHandler interface