Options
All
  • Public
  • Public/Protected
  • All
Menu

React Jacdac - v1.1.11

Index

Functions

  • JacdacProvider(props: { children: ReactNode; initialBus?: JDBus }): Element
  • Mounts a Jacdac context with the provided bus. The bus should be instantiated outside of the React tree to work well with hot-reload solution (avoiding the bus to constantly reset)

    Parameters

    • props: { children: ReactNode; initialBus?: JDBus }
      • children: ReactNode
      • Optional initialBus?: JDBus

    Returns Element

  • useBus(): JDBus
  • Grabs the Jacdac singleton bus from the current Jacdac context. Throws an error if bus is missing.

    Returns JDBus

  • useChange<TEventSource, TValue>(node: TEventSource, query?: (n: TEventSource) => TValue, deps?: DependencyList, isEqual?: (a: TValue, b: TValue) => boolean): TValue
  • A hook that tracks the CHANGE event in a Jacdac component and reruns, caches the query. The query is not part of the dependency checking.

    Type parameters

    • TEventSource: IEventSource

    • TValue

    Parameters

    • node: TEventSource

      JDOM element

    • Optional query: (n: TEventSource) => TValue

      query run whenever a change is signaled by the component

        • (n: TEventSource): TValue
        • Parameters

          • n: TEventSource

          Returns TValue

    • Optional deps: DependencyList

      optional list of hooks dependencies

    • Optional isEqual: (a: TValue, b: TValue) => boolean
        • (a: TValue, b: TValue): boolean
        • Parameters

          • a: TValue
          • b: TValue

          Returns boolean

    Returns TValue

  • useDeviceImage(specification: DeviceSpec, size?: "avatar" | "lazy" | "catalog" | "preview" | "full" | "list", deps?: DependencyList): string
  • Parameters

    • specification: DeviceSpec
    • Optional size: "avatar" | "lazy" | "catalog" | "preview" | "full" | "list"
    • Optional deps: DependencyList

    Returns string

  • useDeviceProductIdentifier(device: JDDevice, options?: RegisterOptions, deps?: DependencyList): number
  • useDeviceSpecification(device: JDDevice, options?: RegisterOptions, deps?: DependencyList): DeviceSpec
  • A hook that resolves the product specification if any.

    Parameters

    • device: JDDevice
    • Optional options: RegisterOptions
    • Optional deps: DependencyList

    Returns DeviceSpec

    product specification or undefined if missing or unknown

  • useDeviceSpecificationFromIdentifier(id: string): DeviceSpec
  • useDeviceSpecificationFromProductIdentifier(id: number): DeviceSpec
  • useDeviceSpecifications(options?: DeviceSpecificationOptions): jdspec.DeviceSpec[]
  • Gets the list of known Jacdac modules from a central repository

    Parameters

    • Optional options: DeviceSpecificationOptions

    Returns jdspec.DeviceSpec[]

  • useDevices(options?: DeviceFilter, deps?: DependencyList): JDDevice[]
  • A hook that returns an updated list of devices on the bus.

    Parameters

    • Optional options: DeviceFilter

      device filters

    • Optional deps: DependencyList

      optional list of dependencies (excluding filter options)

    Returns JDDevice[]

  • useEvent(service: JDService, identifier: number, deps?: DependencyList): JDEvent
  • Gets the event JDOM node from the service

    Parameters

    • service: JDService

      service JDOM node

    • identifier: number

      event identifier

    • Optional deps: DependencyList

    Returns JDEvent

    event JDOM node if any

  • useEventRaised<TEventSource, TValue>(eventName: string | string[], node: TEventSource, query: (n: TEventSource) => TValue, deps?: DependencyList, isEqual?: (a: TValue, b: TValue) => boolean): TValue
  • A hook to track event and update a state snapshot

    Type parameters

    • TEventSource: IEventSource

    • TValue

    Parameters

    • eventName: string | string[]
    • node: TEventSource
    • query: (n: TEventSource) => TValue
        • (n: TEventSource): TValue
        • Parameters

          • n: TEventSource

          Returns TValue

    • Optional deps: DependencyList
    • Optional isEqual: (a: TValue, b: TValue) => boolean
        • (a: TValue, b: TValue): boolean
        • Parameters

          • a: TValue
          • b: TValue

          Returns boolean

    Returns TValue

  • useEventReceived(event: JDEvent, handler: (event: JDEvent) => void, deps?: DependencyList): void
  • Registers a handler to run whenever the event is received from the bus

    Parameters

    • event: JDEvent

      event to listen

    • handler: (event: JDEvent) => void

      handler, not part of depenency list

        • (event: JDEvent): void
        • Parameters

          • event: JDEvent

          Returns void

    • Optional deps: DependencyList

    Returns void

  • useProxy(force: boolean): void
  • A hook to force brains into proxy mode.

    Parameters

    • force: boolean

    Returns void

  • useRegister(service: JDService, identifier: number, deps?: DependencyList): JDRegister
  • A hook that resolves the register of a service, given the register code.

    Parameters

    • service: JDService

      service to query

    • identifier: number

      register code

    • deps: DependencyList = []

    Returns JDRegister

    register JDOM node, if supported in the specification

  • useRegisterBoolValue(register: JDRegister, options?: RegisterOptions, deps?: DependencyList): boolean
  • A hook that reads and update the value of a boolean register

    Parameters

    • register: JDRegister

      register to listen for changes

    • Optional options: RegisterOptions
    • deps: DependencyList = []

    Returns boolean

    value of the register. undefined if missing

  • useRegisterHumanValue(register: JDRegister, options?: HumanRegisterOptions, deps?: DependencyList): string
  • A hook that reads and update the human friendly value of a register

    Parameters

    • register: JDRegister

      register to listen for changes

    • Optional options: HumanRegisterOptions
    • deps: DependencyList = []

    Returns string

    human friendly value of the register. "???" if missing.

  • useRegisterValue<T>(register: JDRegister, options?: RegisterOptions, deps?: DependencyList): T
  • A hook that reads and update the unpacked value of a register

    Type parameters

    • T: any[]

    Parameters

    • register: JDRegister

      register to listen for changes

    • Optional options: RegisterOptions
    • deps: DependencyList = []

    Returns T

    unpacked value of the register. Empty array if missing.

  • useRoleManager(): RoleManager
  • useRoles<TRoles>(bindings: TRoles, deps?: DependencyList): { roleManager: RoleManager; roles: Record<keyof TRoles, JDService>; updates: Record<keyof TRoles, (service: JDService) => void> }
  • A hook that allow to create a service role mapping

    Type parameters

    Parameters

    • bindings: TRoles
    • deps: DependencyList = []

    Returns { roleManager: RoleManager; roles: Record<keyof TRoles, JDService>; updates: Record<keyof TRoles, (service: JDService) => void> }

    • roleManager: RoleManager
    • roles: Record<keyof TRoles, JDService>
    • updates: Record<keyof TRoles, (service: JDService) => void>
  • useServiceSpecification(service: JDService): ServiceSpec
  • useServiceSpecificationFromServiceClass(serviceClass: number): ServiceSpec
  • useServices(options?: ServiceFilter & DeviceFilter, deps?: DependencyList): JDService[]
  • A hook that returns an updated list of services on the bus.

    Parameters

    • Optional options: ServiceFilter & DeviceFilter

      service filters

    • Optional deps: DependencyList

      optional list of dependencies (excluding filter options)

    Returns JDService[]

    list of services matching the filter

Generated using TypeDoc