Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/data

The module responsible for loading data required by plannable, including but not limited to semester list, semester course data, building data, etc.

Index

Type aliases

SectionTableItem

SectionTableItem: Omit<SectionFields, "course">

Functions

defaultValidator

  • defaultValidator<T_JSON>(x: T_JSON | null): x is T_JSON

fallback

  • fallback<T>(temp: FallBackable<T>, __namedParameters?: { succMsg: string; timeoutTime: number; errMsg: any; warnMsg: any }): Promise<NotiMsg<T>>
  • Await the promise on temp.new to resolve. If timed out, return the old data on temp.old.

    Type parameters

    • T

    Parameters

    • temp: FallBackable<T>
    • Default value __namedParameters: { succMsg: string; timeoutTime: number; errMsg: any; warnMsg: any } = {}
      • succMsg: string
      • timeoutTime: number
      • errMsg: function
        • errMsg(x: string): string
      • warnMsg: function
        • warnMsg(x: string): string

    Returns Promise<NotiMsg<T>>

    the payload with an appropriate message

loadBuildingSearcher

  • Try to load the array of the names of buildings from localStorage. If it expires or does not exist, load a fresh one from the data backend and store it in localStorage.

    storage key: "buildingList"

    Parameters

    • Default value force: boolean = false

    Returns Promise<NotiMsg<string[]>>

loadFromCache

  • loadFromCache<T, T_JSON>(key: string, request: () => Promise<T>, construct: (x: T_JSON) => T, __namedParameters: { expireTime: number; force: boolean; validator: (x: T_JSON | null) => x is T_JSON; parse: any; store: any }): FallBackable<T>
  • The template function that helps to load data from cache/remote

    Example usage:

    see

    loadTimeMatrix,loadBuildingSearcher,loadSemesterList,loadSemesterData

    Type parameters

    • T

      the type of the object to construct

    • T_JSON: Expirable

      the JSON-serializable representation of the object T

    Parameters

    • key: string

      the key in the localStorage

    • request: () => Promise<T>

      the async function used to request data from remote, if local data expires or does not exist

    • construct: (x: T_JSON) => T

      function to construct the actual object T from its JSON-serializable representation T_JSON

        • (x: T_JSON): T
        • Parameters

          • x: T_JSON

          Returns T

    • __namedParameters: { expireTime: number; force: boolean; validator: (x: T_JSON | null) => x is T_JSON; parse: any; store: any }
      • expireTime: number
      • force: boolean
      • validator: (x: T_JSON | null) => x is T_JSON
          • (x: T_JSON | null): x is T_JSON
          • Parameters

            • x: T_JSON | null

            Returns x is T_JSON

      • parse: function
        • parse(x: null | string): any
      • store: function
        • store(x: T): T

    Returns FallBackable<T>

loadSemesterData

  • Try to load semester data from localStorage. If data expires/does not exist, fetch a fresh set of data from Lou's list and save to localStorage.

    storage key: 1198data

    Parameters

    • semester: SemesterJSON

      the semester to load data

    • Default value force: boolean = false

      force update

    Returns Promise<FallBackable<Catalog>>

loadSemesterList

loadTimeMatrix

  • Try to load the walking time matrix between buildings from localStorage. If it expires or does not exist, load a fresh one from the data backend and store it in localStorage.

    storage key: "timeMatrix"

    Parameters

    • Default value force: boolean = false

    Returns Promise<NotiMsg<Int32Array>>

retrieveFromDB

saveToDB

setupTimeMatrix

  • setupTimeMatrix(timeMatrix: Int32Array): void

Generated using TypeDoc