From ad61f58644b3f0fac451dbc5b869471edcad0cf4 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 20 Feb 2021 22:45:07 +0800 Subject: ... --- FrontEnd/src/app/common.ts | 47 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'FrontEnd/src/app/common.ts') diff --git a/FrontEnd/src/app/common.ts b/FrontEnd/src/app/common.ts index 681568bb..1a4f6dda 100644 --- a/FrontEnd/src/app/common.ts +++ b/FrontEnd/src/app/common.ts @@ -1,49 +1,18 @@ -import React from "react"; -import { Observable, Subject } from "rxjs"; import { TFunction } from "i18next"; +export type BootstrapThemeColor = + | "primary" + | "secondary" + | "success" + | "danger" + | "warning" + | "info"; + // This error is thrown when ui goes wrong with bad logic. // Such as a variable should not be null, but it does. // This error should never occur. If it does, it indicates there is some logic bug in codes. export class UiLogicError extends Error {} -export function useEventEmiiter(): [() => Observable, () => void] { - const ref = React.useRef | null>(null); - - return React.useMemo(() => { - const getter = (): Subject => { - if (ref.current == null) { - ref.current = new Subject(); - } - return ref.current; - }; - const trigger = (): void => { - getter().next(null); - }; - return [getter, trigger]; - }, []); -} - -export function useValueEventEmiiter(): [ - () => Observable, - (value: T) => void -] { - const ref = React.useRef | null>(null); - - return React.useMemo(() => { - const getter = (): Subject => { - if (ref.current == null) { - ref.current = new Subject(); - } - return ref.current; - }; - const trigger = (value: T): void => { - getter().next(value); - }; - return [getter, trigger]; - }, []); -} - export type I18nText = | string | { type: "custom"; value: string } -- cgit v1.2.3