Skip to content

Instantly share code, notes, and snippets.

@neatorobito
Created December 14, 2019 17:34
Show Gist options
  • Save neatorobito/6469b6bff52f461460f46ef7b1ded228 to your computer and use it in GitHub Desktop.
Save neatorobito/6469b6bff52f461460f46ef7b1ded228 to your computer and use it in GitHub Desktop.
Typescript definitions for the almy library
export = almy;
declare const almy: {
almy: {
/**
* Re-initializes the state store.
* @returns None
*/
create(): void;
/**
* Creates or updates the value in the state store and dispatches notifications to any subscribed handlers.
*
* @param key - The name of the value
* @param value - The value
*
*/
dispatch(key : string, value : any): void;
/**
* Retrieves a value from the state store.
*
* @param key - The name of the value
* @returns The value
*
*/
state(key : string): any;
/**
* Subscribes to dispatched events.
*
* @param key - The name of the value
* @param callback - A function that is called when the value is updated
*
* @note If a event has been dispatched before, the callback will be called immediately after subscribing.
*/
subscribe(key : string, callback : (value : any) => void): void;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment