From 4145a5ebac9ad94c60bb8dacbac283f751ff76e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 6 Mar 2019 14:52:31 +0100 Subject: [PATCH] add some docstring --- web/static/src/ts/core/event_bus.ts | 3 +++ web/static/src/ts/core/utils.ts | 11 ++++++++++- web/static/src/ts/store/action_manager_mixin.ts | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/web/static/src/ts/core/event_bus.ts b/web/static/src/ts/core/event_bus.ts index bcbd9fb6..9fe6cfe2 100644 --- a/web/static/src/ts/core/event_bus.ts +++ b/web/static/src/ts/core/event_bus.ts @@ -68,6 +68,9 @@ export class EventBus { } } + /** + * Remove all subscriptions. + */ clear() { this.subscriptions = {}; } diff --git a/web/static/src/ts/core/utils.ts b/web/static/src/ts/core/utils.ts index a0d33453..303096d5 100644 --- a/web/static/src/ts/core/utils.ts +++ b/web/static/src/ts/core/utils.ts @@ -27,7 +27,10 @@ export function htmlTrim(s: string): string { return result; } -export function idGenerator(): (() => number) { +/** + * Create a function that will generate unique id numbers + */ +export function idGenerator(): () => number { let nextID = 1; return () => nextID++; } @@ -88,6 +91,12 @@ interface Tree { children: T[]; } +/** + * Find a node in a tree. + * + * This will traverse the tree (depth first) and return the first child that + * matches the predicate, if any + */ export function findInTree>( tree: T, predicate: (t: T) => boolean diff --git a/web/static/src/ts/store/action_manager_mixin.ts b/web/static/src/ts/store/action_manager_mixin.ts index f0622e1b..c323a5ba 100644 --- a/web/static/src/ts/store/action_manager_mixin.ts +++ b/web/static/src/ts/store/action_manager_mixin.ts @@ -3,6 +3,10 @@ import { rpcMixin } from "./rpc_mixin"; import { Widget } from "../widget"; import { View } from "../views/view"; +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + export type Context = { [key: string]: any }; export interface CommonActionInfo {