Add TS part of RegisteredFunction API

This commit is contained in:
Steve Sanderson 2017-12-15 20:01:23 +00:00
parent 9e92c21a2f
commit 7daec15a8e
1 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
const registeredFunctions = {};
// Code in Mono 'driver.c' looks for the registered functions here
window['__blazorRegisteredFunctions'] = registeredFunctions;
export function registerFunction(identifier: string, implementation: Function) {
if (registeredFunctions.hasOwnProperty(identifier)) {
throw new Error(`A function with the identifier '${identifier}' has already been registered.`);
}
registeredFunctions[identifier] = implementation;
}