Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface INavigator<T>

An interface for component class having navigation mechanism. For example, a menu bar having menu items to navigate through each page should implement this interface.

author

shiorin, tee4cute

see

INavigatee

Type parameters

  • T: INavigatee

    A type of navigatee item can be navigated by this navigator.

Hierarchy

  • INavigator

Implemented by

Index

Methods

addItem

  • addItem(item: T): boolean
  • Add a new navigatee item (INavigatee) into this navigator. This method will check that there already is the given item in this navigator or not. If yes, the item will not be added and this method will return false.

    Parameters

    • item: T

      A new navigatee item (INavigatee) to be added into this navigator.

    Returns boolean

    Returns true if the given item is newly added into this navigator. Otherwise, returns false.

containsItem

  • containsItem(item: T): boolean
  • To check that the given navigatee item (INavigatee) is currently in this navigator or not.

    Parameters

    • item: T

      The navigatee item to be checked.

    Returns boolean

    Returns true if the given item is currently in this navigator. Otherwise, returns false.

getActiveIndex

  • getActiveIndex(): number
  • Get current active navigatee (INavigatee) item's index. The value returned from this method must be an index of array returning from method getItems.

    Returns number

    The index of navigatee (INavigatee) item currently active. Returns -1 if there is no current active item.

getActiveItem

  • getActiveItem(): T
  • Get current active navigatee (INavigatee) item. In most scenarios, this method should return the item representing the component (page) being displayed by this navigator.

    Returns T

    The current active navigatee (INavigatee) item being displayed by this navigator. Returns null if there is no current active item.

getItemByIndex

  • getItemByIndex(idx: number): T
  • Get the navigatee item (INavigatee) by the given idx.

    Parameters

    • idx: number

      The navigatee item array index (starting from 0).

    Returns T

    The navigatee item (INavigatee) at the specified idx. If the specified idx is out of bound, this method will returns null without throwing any exceptions.

getItemByName

  • getItemByName(name: string): T
  • Get the navigatee item (INavigatee) by the given item name.

    Parameters

    • name: string

      The name of navigatee item.

    Returns T

    The navigatee item having the name (INavigatee.getName) matches the name passed as a parameter. Returns null if not found.

getItemCount

  • getItemCount(): number
  • Get number of navigatee (INavigatee) items can be navigated by this navigator. This must be the same value as getItems's length.

    Returns number

    The navigatee (INavigatee) item count.

getItemIndex

  • getItemIndex(item: T): number
  • Find the index of the given navigatee item in the items array returned from method getItems.

    Parameters

    • item: T

      The navigatee item to find the index.

    Returns number

    The index of the given item. Returns -1 if not found.

getItemIndexByName

  • getItemIndexByName(name: string): number
  • Find the index of navigatee item having item name (INavigatee.getName) matches the name passed as a parameter.

    Parameters

    • name: string

      The name of navigatee item to find the index.

    Returns number

    The index of the navigatee item having item name (INavigatee.getName) matches the name passed as a parameter. Returns -1 if not found.

getItems

  • getItems(): T[]
  • Get navigatee (INavigatee) items can be navigated by this navigator.

    Returns T[]

    An array of navigatee (INavigatee) items can be navigated by this navigator.

navigateTo

  • navigateTo(item: T, options?: any): Promise<boolean>
  • Navigate this navigator to the given item (INavigatee). This method returns Promise to allow the navigation to be asynchronous. If the item is not in this navigator, this method will suddenly return resolved Promise having result value "false". Otherwise, it'll return a Promise which will be resolved when the navigation is done with result value "true". The navigated-to item will be set active flag to true and all other navigatee items in this navigator will be set active flag to false.

    Parameters

    • item: T

      The navigatee item to be navigated to.

    • Optional options: any

      The options object used for the navigation. This will depend on each navigator implementation.

    Returns Promise<boolean>

    A Promise which will be resolved when the navigation is done with result value "true". If the given item is not in this navigator, this method will return a resolved Promise with result value "false".

navigateToIndex

  • navigateToIndex(idx: number, options?: any): Promise<boolean>
  • Navigate this navigator to the given navigatee item idx. This method returns Promise to allow the navigation to be asynchronous. If the given idx is out of bound, this method will suddenly return resolved Promise having result value "false". Otherwise, it'll return a Promise which will be resolved when the navigation is done with result value "true". The navigated-to item will be set active flag to true and all other navigatee items in this navigator will be set active flag to false.

    Parameters

    • idx: number

      The navigatee item idx to be navigated to.

    • Optional options: any

      The options object used for the navigation. This will depend on each navigator implementation.

    Returns Promise<boolean>

    A Promise which will be resolved when the navigation is done with result value "true". If the given idx is out of bound, this method will return a resolved Promise with result value "false".

navigateToName

  • navigateToName(name: string, options?: any): Promise<boolean>
  • Navigate this navigator to the given navigatee item name. This method returns Promise to allow the navigation to be asynchronous. If the given item name does not exist, this method will suddenly return resolved Promise having result value "false". Otherwise, it'll return a Promise which will be resolved when the navigation is done with result value "true". The navigated-to item will be set active flag to true and all other navigatee items in this navigator will be set active flag to false.

    Parameters

    • name: string

      The navigatee item name to be navigated to.

    • Optional options: any

      The options object used for the navigation. This will depend on each navigator implementation.

    Returns Promise<boolean>

    A Promise which will be resolved when the navigation is done with result value "true". If the given item name does not exist, this method will return a resolved Promise with result value "false".

removeItem

  • removeItem(item: T): boolean
  • Remove the given navigatee item (INavigatee) from this navigator. If the given item is not currently in this navigator, this method will do nothing and return false.

    Parameters

    • item: T

      The navigatee item to be removed from this navigator.

    Returns boolean

    Returns true if the given item is in this navigator and successfully removed. Otherwise, returns false.

reset

  • reset(): void
  • Reset this navigator to the original state.

    Returns void

setItems

  • setItems(items: T[]): void
  • Set navigatee items (INavigatee) into this navigator.

    Parameters

    • items: T[]

      The navigatee items (INavigatee) to be set into this navigator.

    Returns void

Generated using TypeDoc