Skip to content

Commit

Permalink
More typings
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Jan 27, 2021
1 parent 4a97962 commit cf7c2ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions packages/voila/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ export class WidgetManager extends JupyterLabManager {
return view.pWidget;
}

async loadClass(className, moduleName, moduleVersion) {
async loadClass(
className: string,
moduleName: string,
moduleVersion: string
): Promise<any> {
if (
moduleName === '@jupyter-widgets/base' ||
moduleName === '@jupyter-widgets/controls' ||
Expand All @@ -151,8 +155,7 @@ export class WidgetManager extends JupyterLabManager {
}
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
restoreWidgets(notebook): Promise<void> {
restoreWidgets(notebook: INotebookModel): Promise<void> {
return Promise.resolve();
}

Expand All @@ -174,7 +177,7 @@ export class WidgetManager extends JupyterLabManager {
});
}

async _build_models() {
async _build_models(): Promise<{ [key: string]: base.WidgetModel }> {
const comm_ids = await this._get_comm_info();
const models = {};
/**
Expand Down Expand Up @@ -215,7 +218,9 @@ export class WidgetManager extends JupyterLabManager {
return models;
}

async _update_comm(comm) {
async _update_comm(
comm: base.IClassicComm
): Promise<{ comm: base.IClassicComm; msg: any }> {
return new Promise((resolve, reject) => {
comm.on_msg(async msg => {
if (msg.content.data.buffer_paths) {
Expand Down
6 changes: 5 additions & 1 deletion packages/voila/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const delay = sec => new Promise(resolve => setTimeout(resolve, sec * 1000));
* and 'room' number of parallel calls.
* Note that the minimum window at which rate is respected is room/rate seconds.
*/
export const batchRateMap = (list, fn, { room, rate }) => {
export const batchRateMap = (
list: string[],
fn: (...args: any[]) => Promise<any>,
{ room, rate }: { room: number; rate: number }
): Promise<any>[] => {
const limit = pLimit(room);
return list.map(async value => {
return new Promise((valueResolve, reject) => {
Expand Down

0 comments on commit cf7c2ac

Please sign in to comment.