Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akrantz/8c72034d739261d2f714dba7d0ea1c8d to your computer and use it in GitHub Desktop.
Save akrantz/8c72034d739261d2f714dba7d0ea1c8d to your computer and use it in GitHub Desktop.
A streaming function that continuously pushes incremental values into an array.
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