Created
May 20, 2019 21:50
-
-
Save akrantz/8c72034d739261d2f714dba7d0ea1c8d to your computer and use it in GitHub Desktop.
A streaming function that continuously pushes incremental values into an array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Streaming function that returns a 2D array of numbers | |
description: >- | |
A streaming function that continuously pushes incremental values into an | |
array. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: >- | |
/** | |
* Increments a value once a second. | |
* @customfunction | |
* @param incrementBy Amount to increment | |
* @param invocation Custom function handler | |
*/ | |
function incrementMatrix(incrementBy: number, invocation: | |
CustomFunctions.StreamingInvocation<number[][]>): void { | |
let current: number = 0; | |
let matrix: number[][] = []; | |
const timer = setInterval(() => { | |
current += incrementBy; | |
matrix.push([current]); | |
invocation.setResult(matrix); | |
}, 1000); | |
invocation.onCanceled = () => { | |
clearInterval(timer); | |
}; | |
} | |
language: typescript | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/client/core.min.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment